def SetPosition(self, track_id, position): if track_id == self._get_trackid(PLAYER.current): position /= MICROSECOND PLAYER.seek(position) else: # treat request as stale pass
def PlaybackStatus(self): if PLAYER.is_playing(): return 'Playing' elif PLAYER.is_paused(): return 'Paused' else: return 'Stopped'
def _delete_event(window, event, exaile): """ window behavior on closing, according to sound menu spec: https://wiki.ubuntu.com/SoundMenu """ if PLAYER.is_playing(): window.hide() else: exaile.gui.main.quit() return True
def __init__(self): self.inhibited = False self.lock = _thread.allocate_lock() # Initialize parent object super().__init__(PLAYER) # Inhibit if player currently playing if PLAYER.is_playing(): self.inhibit()
def on_media_key(key, exaile): from xl.player import PLAYER, QUEUE { 'XF86AudioPlay': PLAYER.toggle_pause, 'XF86AudioStop': PLAYER.stop, 'XF86AudioPrev': QUEUE.prev, 'XF86AudioNext': QUEUE.next, 'XF86AudioPause': PLAYER.toggle_pause, 'XF86AudioMedia': exaile.gui.main.window.present, 'XF86AudioRewind': lambda: PLAYER.seek(0), }[key]()
def __init__(self, bus_name, object_path, interface): try: bus = dbus.SessionBus() obj = bus.get_object(bus_name, object_path) self.iface = dbus.Interface(obj, interface) logger.info('Suspend Bus Acquired') except dbus.DBusException: raise EnvironmentError(bus_name + ' bus not available') self.inhibited = False self.lock = _thread.allocate_lock() # Initialize parent object adapters.PlaybackAdapter.__init__(self, PLAYER) # Inhibit if player currently playing if PLAYER.is_playing(): self.inhibit()
def Volume(self, value): PLAYER.set_volume(value * 100.0)
def Volume(self): # Range: 0.0 ~ 1.0 return PLAYER.get_volume() / 100.0
def Position(self): pos = PLAYER.get_position() / NANOSECOND * MICROSECOND return dbus.Int64(pos)
def Stop(self): PLAYER.stop()
def Seek(self, offset): position = PLAYER.get_position() / NANOSECOND position += offset / MICROSECOND PLAYER.seek(position)
def PlayPause(self): if PLAYER.is_stopped(): QUEUE.play() else: PLAYER.toggle_pause()
def Pause(self): PLAYER.pause()