Commit 0e9aed6a authored by André's avatar André Committed by Philipp Hörist

MusicTrackListener: Get currently playing song asynchronously

Fixes #10339.
parent 26a8b374
Pipeline #6718 passed with stages
in 4 minutes and 17 seconds
......@@ -93,9 +93,7 @@ def start(self):
self._add_player(name)
for name in list(self.players):
info = self._get_playing_track(name)
if info is not None:
self._emit(info)
self._get_playing_track(name)
def stop(self):
for name in list(self.players):
......@@ -154,10 +152,7 @@ def _signal_received(self,
'''Signal handler for PropertiesChanged event'''
log.info('Signal received: %s - %s', interface_name, parameters)
info = self._get_playing_track(user_data[0])
self._emit(info)
self._get_playing_track(user_data[0])
@staticmethod
def _get_music_info(properties):
......@@ -189,18 +184,23 @@ def _get_playing_track(self, name):
'org.freedesktop.DBus.Properties',
None)
try:
result = proxy.call_sync(
"GetAll",
GLib.Variant('(s)', ('org.mpris.MediaPlayer2.Player',)),
Gio.DBusCallFlags.NONE,
-1,
None)
except GLib.Error as error:
log.debug("Could not enable music listener: %s", error.message)
return None
def proxy_call_finished(proxy, res):
try:
result = proxy.call_finish(res)
except GLib.Error as error:
log.debug("Could not enable music listener: %s", error.message)
return
info = self._get_music_info(result[0])
if info is not None:
self._emit(info)
return self._get_music_info(result[0])
proxy.call("GetAll",
GLib.Variant('(s)', ('org.mpris.MediaPlayer2.Player',)),
Gio.DBusCallFlags.NONE,
-1,
None,
proxy_call_finished)
def enable():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment