DBUS-tracklist
Submitted by Mikael Holber
Link to original bug (#743515)
Description
I would like to have an expansion of the DBUS-interface for the "current playlist" or Tracklist. I interface this with python and want to access all metadata of the current playing playlist for my project. For Clementine player and Audacious I can access all information in the playlist with /Tracklist and I wish to have this included in Banshee as well.
I can currently get the current playing song in Rhythmbox with (example with title):
#!/usr/bin/env python
-- coding: utf-8 --
import dbus
bus = dbus.SessionBus() bus.name_has_owner('org.gnome.Rhythmbox3') proxy = bus.get_object('org.gnome.Rhythmbox3','/org/mpris/MediaPlayer2') properties_manager = dbus.Interface(proxy, 'org.freedesktop.DBus.Properties') metadata = properties_manager.Get('org.mpris.MediaPlayer2.Player', 'Metadata')
print "Current track:", metadata[u'xesam:title']
With for example Clementine you can access the songs in the current playing list through Tracklist:
#!/usr/bin/env python
-- coding: utf-8 --
import dbus
bus = dbus.SessionBus() player = bus.get_object('org.mpris.clementine', '/Player') tracklist = bus.get_object('org.mpris.clementine', '/TrackList')
currentsong = tracklist.GetCurrentTrack() #integer, current song playing playlistlength = tracklist.GetLength() #integer, playlist lengths
for i in range(currentsong,currentsong+5): print "Track",i,":", tracklist.GetMetadata(i)[u'title'] i = i+1
Kind regards Mikael Holber - Sweden