Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eta
gajim
Commits
4e1d7a21
Commit
4e1d7a21
authored
18 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
[Gustavo Carneiro] handle stop music in music_track_listener.py. Fixes #564
parent
382b2450
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/music_track_listener.py
+41
-8
41 additions, 8 deletions
src/music_track_listener.py
with
41 additions
and
8 deletions
src/music_track_listener.py
+
41
−
8
View file @
4e1d7a21
...
...
@@ -24,8 +24,9 @@ class MusicTrackInfo(object):
class
MusicTrackListener
(
gobject
.
GObject
):
__gsignals__
=
{
'
music-track-changed
'
:
(
gobject
.
SIGNAL_RUN_LAST
,
None
,
(
object
,))
}
__gsignals__
=
{
'
music-track-changed
'
:
(
gobject
.
SIGNAL_RUN_LAST
,
None
,
(
object
,)),
}
_instance
=
None
@classmethod
...
...
@@ -36,14 +37,39 @@ class MusicTrackListener(gobject.GObject):
def
__init__
(
self
):
super
(
MusicTrackListener
,
self
).
__init__
()
self
.
_last_playing_music
=
None
bus
=
dbus
.
SessionBus
()
## Muine
bus
.
add_signal_receiver
(
self
.
_muine_music_track_change_cb
,
'
SongChanged
'
,
'
org.gnome.Muine.Player
'
)
bus
.
add_signal_receiver
(
self
.
_player_name_owner_changed
,
'
NameOwnerChanged
'
,
'
org.freedesktop.DBus
'
,
arg0
=
'
org.gnome.Muine
'
)
bus
.
add_signal_receiver
(
self
.
_player_playing_changed_cb
,
'
StateChanged
'
,
'
org.gnome.Muine.Player
'
)
## Rhythmbox
bus
.
add_signal_receiver
(
self
.
_rhythmbox_music_track_change_cb
,
'
playingUriChanged
'
,
'
org.gnome.Rhythmbox.Player
'
)
bus
.
add_signal_receiver
(
self
.
_player_name_owner_changed
,
'
NameOwnerChanged
'
,
'
org.freedesktop.DBus
'
,
arg0
=
'
org.gnome.Rhythmbox
'
)
bus
.
add_signal_receiver
(
self
.
_player_playing_changed_cb
,
'
playingChanged
'
,
'
org.gnome.Rhythmbox.Player
'
)
def
_player_name_owner_changed
(
self
,
name
,
old
,
new
):
if
not
new
:
self
.
emit
(
'
music-track-changed
'
,
None
)
def
_player_playing_changed_cb
(
self
,
playing
):
if
playing
:
self
.
emit
(
'
music-track-changed
'
,
self
.
_last_playing_music
)
else
:
self
.
emit
(
'
music-track-changed
'
,
None
)
def
_muine_properties_extract
(
self
,
song_string
):
d
=
dict
((
x
.
strip
()
for
x
in
s1
.
split
(
'
:
'
,
1
))
for
s1
in
song_string
.
split
(
'
\n
'
))
d
=
dict
((
x
.
strip
()
for
x
in
s1
.
split
(
'
:
'
,
1
))
for
s1
in
\
song_string
.
split
(
'
\n
'
))
info
=
MusicTrackInfo
()
info
.
title
=
d
[
'
title
'
]
info
.
album
=
d
[
'
album
'
]
...
...
@@ -67,7 +93,8 @@ class MusicTrackListener(gobject.GObject):
def
_rhythmbox_music_track_change_cb
(
self
,
uri
):
bus
=
dbus
.
SessionBus
()
rbshellobj
=
bus
.
get_object
(
'
org.gnome.Rhythmbox
'
,
'
/org/gnome/Rhythmbox/Shell
'
)
rbshellobj
=
bus
.
get_object
(
'
org.gnome.Rhythmbox
'
,
'
/org/gnome/Rhythmbox/Shell
'
)
rbshell
=
dbus
.
Interface
(
rbshellobj
,
'
org.gnome.Rhythmbox.Shell
'
)
props
=
rbshell
.
getSongProperties
(
uri
)
info
=
self
.
_rhythmbox_properties_extract
(
props
)
...
...
@@ -87,19 +114,22 @@ class MusicTrackListener(gobject.GObject):
if
player
.
GetPlaying
():
song_string
=
player
.
GetCurrentSong
()
song
=
self
.
_muine_properties_extract
(
song_string
)
self
.
_last_playing_music
=
song
return
song
## Check Rhythmbox playing song
if
dbus
.
dbus_bindings
.
bus_name_has_owner
(
bus
.
get_connection
(),
'
org.gnome.Rhythmbox
'
):
rbshellobj
=
bus
.
get_object
(
'
org.gnome.Rhythmbox
'
,
'
/org/gnome/Rhythmbox/Shell
'
)
rbshellobj
=
bus
.
get_object
(
'
org.gnome.Rhythmbox
'
,
'
/org/gnome/Rhythmbox/Shell
'
)
player
=
dbus
.
Interface
(
bus
.
get_object
(
'
org.gnome.Rhythmbox
'
,
'
/org/gnome/Rhythmbox/Player
'
),
'
org.gnome.Rhythmbox.Player
'
)
bus
.
get_object
(
'
org.gnome.Rhythmbox
'
,
'
/org/gnome/Rhythmbox/Player
'
),
'
org.gnome.Rhythmbox.Player
'
)
rbshell
=
dbus
.
Interface
(
rbshellobj
,
'
org.gnome.Rhythmbox.Shell
'
)
uri
=
player
.
getPlayingUri
()
props
=
rbshell
.
getSongProperties
(
uri
)
info
=
self
.
_rhythmbox_properties_extract
(
props
)
self
.
_last_playing_music
=
info
return
info
return
None
...
...
@@ -107,7 +137,10 @@ class MusicTrackListener(gobject.GObject):
# here we test :)
if
__name__
==
'
__main__
'
:
def
music_track_change_cb
(
listener
,
music_track_info
):
print
music_track_info
.
title
if
music_track_info
is
None
:
print
"
Stop!
"
else
:
print
music_track_info
.
title
listener
=
MusicTrackListener
.
get
()
listener
.
connect
(
'
music-track-changed
'
,
music_track_change_cb
)
track
=
listener
.
get_playing_track
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment