From a964487e2fcd11946b5f95ab36b20cbd1bea4a57 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 9 Dec 2010 11:36:33 +0000 Subject: moving towards testing proposed playlists api --- src/mpris2-controller.vala | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'src/mpris2-controller.vala') diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 59e3122..2c19606 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -21,8 +21,8 @@ using Dbusmenu; [DBus (name = "org.freedesktop.DBus.Properties")] public interface FreeDesktopProperties : Object{ - public signal void PropertiesChanged(string source, HashTable changed_properties, - string[] invalid); + public signal void PropertiesChanged (string source, HashTable changed_properties, + string[] invalid ); } /* @@ -34,13 +34,14 @@ public class Mpris2Controller : GLib.Object public static const string root_interface = "org.mpris.MediaPlayer2" ; public MprisRoot mpris2_root {get; construct;} public MprisPlayer player {get; construct;} + public MprisPlaylists playlists {get; construct;} public FreeDesktopProperties properties_interface {get; construct;} public PlayerController owner {get; construct;} - + public Mpris2Controller(PlayerController ctrl) { - GLib.Object(owner: ctrl); + GLib.Object(owner: ctrl); } construct{ @@ -51,6 +52,9 @@ public class Mpris2Controller : GLib.Object this.player = Bus.get_proxy_sync ( BusType.SESSION, root_interface.concat(".").concat(this.owner.mpris_name), "/org/mpris/MediaPlayer2" ); + this.playlists = Bus.get_proxy_sync ( BusType.SESSION, + root_interface.concat(".").concat(this.owner.mpris_name), + "/org/mpris/MediaPlayer2" ); this.properties_interface = Bus.get_proxy_sync ( BusType.SESSION, "org.freedesktop.Properties.PropertiesChanged", @@ -127,12 +131,14 @@ public class Mpris2Controller : GLib.Object GLib.HashTable? cleaned_metadata = this.clean_metadata(); this.owner.custom_items[PlayerController.widget_order.METADATA].update(cleaned_metadata, MetadataMenuitem.attributes_format()); + this.fetch_playlists(); } public void transport_update(TransportMenuitem.action command) { debug("transport_event input = %i", (int)command); if(command == TransportMenuitem.action.PLAY_PAUSE){ + this.fetch_playlists(); this.player.PlayPause.begin(); } else if(command == TransportMenuitem.action.PREVIOUS){ @@ -143,6 +149,26 @@ public class Mpris2Controller : GLib.Object } } + public void fetch_playlists() + { + if (this.playlists == null){ + warning("Playlists object is null"); + return; + } + PlaylistDetails[] current_playlists = this.playlists.GetPlaylists(0, 10, "Alphabetical", false); + if( current_playlists != null ){ + debug( "Size of the playlist array = %i", current_playlists.length ); + PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem; + playlists_item.update(current_playlists); + /*foreach(PlaylistDetails detail in current_playlists){ + debug( "Playlist Name = %s", detail.name); + debug( "Playlist path = %s", detail.path); + debug( "Playlist icon path = %s", detail.icon_path); + debug(" \n \n \n \n \n "); + }*/ + } + } + public bool connected() { return (this.player != null && this.mpris2_root != null); -- cgit v1.2.3