Beispiel #1
0
import DBusBase

class GMusicBrowserkHandler(DBusBase.DBusBase):
    '''Handler for gmusicbrowser'''

    def __init__(self, iface_name = 'org.gmusicbrowser',
                 iface_path='/org/gmusicbrowser'):
        DBusBase.DBusBase.__init__(self, iface_name, iface_path)

    def is_running(self):
        '''Returns a True if the player is running'''
        return self.is_name_active(self.iface_name)

    def is_playing(self):
        '''Returns True if a song is being played'''
        if self.is_running():
            return bool(self.iface.Playing())

        return False

    def get_current_song(self):
        '''Returns the current song in the correct format'''
        if self.is_playing():
            song = self.iface.CurrentSong()
            return songretriever.Song(song['artist'],
                                      song['album'],
                                      song['title'])

songretriever.register('gmusicbrowser', GMusicBrowserkHandler)
Beispiel #2
0
    def is_running(self):
        '''returns True if the player is running'''
        try:
            self.client.status()
            return True
        except mpd.ConnectionError:
            return self.reconnect()

    def is_playing(self):
        '''returns True if the player is playing a song'''
        if not self.is_running():
            return False

        status = self.client.status()

        return status.get('state', None) == 'play'

    def get_current_song(self):
        '''returns the current song or None if no song is playing'''
        if not self.is_running() or not self.is_playing():
            return None

        info = self.client.currentsong()
        return songretriever.Song(info.get('artist', '?'),
                info.get('album', '?'),
                info.get('title', '?'),
                info.get('file', '?'))

songretriever.register('mpd', Handler)
Beispiel #3
0
        DBusBase.DBusBase.__init__(self, iface_name, iface_path)

    def reconnect(self):
        '''method to attemp a reconnection, via dbus, this is only
        called if the bus object is not initialized'''
        if DBusBase.DBusBase.reconnect(self):
            rbshellobj   = self.bus.get_object(self.iface_name, SHELL_PATH)
            self.rbshell = self.module.Interface(rbshellobj, SHELL_NAME)
            return True

        return False

    def is_playing(self):
        '''Returns True if a song is being played'''
        if self.is_running():
            return bool(self.iface.getPlaying())

        return False

    def get_current_song(self):
        '''Returns the current song in the correct format'''
        if self.is_playing():
            uri  = self.iface.getPlayingUri()
            song = self.rbshell.getSongProperties(uri)

            return songretriever.Song(song['artist'],
                                      song['album'],
                                      song['title'])

songretriever.register('rhythmbox', RhythmboxHandler)
Beispiel #4
0
import DBusBase

class AmarokHandler(DBusBase.DBusBase):
    '''Handler for Amarok2'''

    def __init__(self, iface_name = 'org.mpris.amarok',
                 iface_path='/TrackList'):
        DBusBase.DBusBase.__init__(self, iface_name, iface_path)

    def is_playing(self):
        '''Returns True if a song is being played'''
        if self.is_running():
            is_playing_iface = self.bus.get_object(self.iface_name, '/Player')
            if is_playing_iface:
                status = is_playing_iface.GetStatus()
                if status[0] == 0:
                    return True
        return False

    def get_current_song(self):
        '''Returns the current song in the correct format'''
        if self.is_playing():
            track = self.iface.GetCurrentTrack()
            song = self.iface.GetMetadata(track)
            return songretriever.Song(song['artist'],
                                      song['album'],
                                      song['title'],
                                      song['location'])

songretriever.register('amarok2', AmarokHandler)