def start(self): PlayerAdapter.start(self) try: bus = dbus.SessionBus() proxy = bus.get_object("org.mpris.%s" % self.__name, "/Player") self._mp_p = dbus.Interface(proxy, "org.freedesktop.MediaPlayer") proxy = bus.get_object("org.mpris.%s" % self.__name, "/TrackList") self._mp_t = dbus.Interface(proxy, "org.freedesktop.MediaPlayer") except DBusException as e: raise StandardError("dbus error: %s" % e) try: self.__dbus_signal_handler = ( self._mp_p.connect_to_signal("TrackChange", self._notify_track), self._mp_p.connect_to_signal("StatusChange", self._notify_status), self._mp_p.connect_to_signal("CapsChange", self._notify_caps), self._mp_t.connect_to_signal("TrackListChange", self._notify_tracklist_change), ) except DBusException as e: raise StandardError("dbus error: %s" % e) try: self._mp_p.GetStatus(reply_handler=self._notify_status, error_handler=self._dbus_error) self._mp_p.GetMetadata(reply_handler=self._notify_track, error_handler=self._dbus_error) self._mp_p.GetCaps(reply_handler=self._notify_caps, error_handler=self._dbus_error) except DBusException as e: # this is not necessarily a fatal error log.warning("dbus error: %s" % e)
def __init__( self, name, display_name=None, poll=2.5, mime_types=None, rating=False, extra_file_actions=None, extra_playlist_actions=None, ): display_name = display_name or name if rating: max_rating = 5 else: max_rating = 0 all_file_actions = FILE_ACTIONS + tuple(extra_file_actions or ()) PlayerAdapter.__init__( self, display_name, max_rating=max_rating, playback_known=True, volume_known=True, repeat_known=True, shuffle_known=True, progress_known=True, file_actions=all_file_actions, mime_types=mime_types, ) self.__playlist_actions = PLAYLIST_ACTIONS if self.config.getx("playlist-jump-enabled", "0", int): self.__playlist_actions.append(IA_JUMP) if extra_playlist_actions: self.__playlist_actions.extend(extra_playlist_actions) self.__name = name self.__dbus_signal_handler = () self._mp_p = None self._mp_t = None self._repeat = False self._shuffle = False self._playing = PLAYBACK_STOP self.__volume = 0 self.__progress_now = 0 self.__progress_max = 0 self.__can_pause = False self.__can_play = False self.__can_seek = False self.__can_next = False self.__can_prev = False self.__can_tracklist = False log.debug("init done")
def __init__(self, name, display_name=None, poll=2.5, mime_types=None, rating=False, extra_file_actions=None, extra_playlist_actions=None): display_name = display_name or name if rating: max_rating = 5 else: max_rating = 0 all_file_actions = FILE_ACTIONS + tuple(extra_file_actions or ()) PlayerAdapter.__init__(self, display_name, max_rating=max_rating, playback_known=True, volume_known=True, repeat_known=True, shuffle_known=True, progress_known=True, file_actions=all_file_actions, mime_types=mime_types) self.__playlist_actions = PLAYLIST_ACTIONS if self.config.getx("playlist-jump-enabled", "0", int): self.__playlist_actions.append(IA_JUMP) if extra_playlist_actions: self.__playlist_actions.extend(extra_playlist_actions) self.__name = name self.__dbus_signal_handler = () self._mp_p = None self._mp_t = None self._repeat = False self._shuffle = False self._playing = PLAYBACK_STOP self.__volume = 0 self.__progress_now = 0 self.__progress_max = 0 self.__can_pause = False self.__can_play = False self.__can_seek = False self.__can_next = False self.__can_prev = False self.__can_tracklist = False log.debug("init done")
def stop(self): PlayerAdapter.stop(self) for handler in self.__dbus_signal_handler: handler.remove() self.__dbus_signal_handler = () self._mp_p = None self._mp_t = None
def start(self): PlayerAdapter.start(self) try: bus = dbus.SessionBus() proxy = bus.get_object("org.mpris.%s" % self.__name, "/Player") self._mp_p = dbus.Interface(proxy, "org.freedesktop.MediaPlayer") proxy = bus.get_object("org.mpris.%s" % self.__name, "/TrackList") self._mp_t = dbus.Interface(proxy, "org.freedesktop.MediaPlayer") except DBusException, e: raise StandardError("dbus error: %s" % e)