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 From f3b321919e3390f3d3af2eea33ad71611616ce61 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 10 Dec 2010 13:02:16 +0000 Subject: playlist widget population --- src/mpris2-controller.vala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/mpris2-controller.vala') diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 2c19606..0bd5562 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -138,7 +138,6 @@ public class Mpris2Controller : GLib.Object { 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){ @@ -160,12 +159,13 @@ public class Mpris2Controller : GLib.Object 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){ + foreach(PlaylistDetails detail in current_playlists){ + debug(" \n \n "); 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 "); - }*/ + debug(" \n \n "); + } } } -- cgit v1.2.3 From 93190886959bfa16b835794a4a12a9a945e7777e Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 10 Dec 2010 15:36:44 +0000 Subject: proposed extension proven and observations gathered --- src/mpris2-controller.vala | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/mpris2-controller.vala') diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 0bd5562..94e82d5 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -180,4 +180,18 @@ public class Mpris2Controller : GLib.Object this.mpris2_root.Raise.begin(); } } + + public void activate_playlist (ObjectPath path) + { + if(this.playlists == null){ + warning("playlists mpris instance is null !"); + return; + } + try{ + this.playlists.ActivatePlaylist.begin(path); + } + catch(IOError e){ + debug("Could not activate playlist %s because %s", (string)path, e.message); + } + } } \ No newline at end of file -- cgit v1.2.3 From 032797fd7a92bc8a4fd979ddc12cacb0918ca73b Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Fri, 17 Dec 2010 12:48:03 +0000 Subject: proved active-playlist prop use-case --- src/mpris2-controller.vala | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src/mpris2-controller.vala') diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 94e82d5..d6f27ec 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -18,9 +18,8 @@ with this program. If not, see . */ using Dbusmenu; - [DBus (name = "org.freedesktop.DBus.Properties")] - public interface FreeDesktopProperties : Object{ +public interface FreeDesktopProperties : Object{ public signal void PropertiesChanged (string source, HashTable changed_properties, string[] invalid ); } @@ -91,6 +90,11 @@ public class Mpris2Controller : GLib.Object metadata.property_set_bool ( MENUITEM_PROP_VISIBLE, metadata.populated(MetadataMenuitem.attributes_format())); } + Variant? playlist_v = changed_properties.lookup("ActivePlaylist"); + if ( playlist_v != null ){ + debug (" WE HAVE PLAYLIST CHANGE EVENT DETECTED "); + this.fetch_active_playlist(); + } } private GLib.HashTable? clean_metadata() @@ -131,7 +135,7 @@ 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(); + this.fetch_playlists(); } public void transport_update(TransportMenuitem.action command) @@ -169,6 +173,22 @@ public class Mpris2Controller : GLib.Object } } + public void fetch_active_playlist() + { + if (this.playlists == null && this.playlists.ActivePlaylist.valid == true){ + warning("Playlists object is null and we have an active playlist"); + return; + } + + PlaylistDetails active_details = this.playlists.ActivePlaylist.active_playlist; + debug(" \n \n "); + debug( "Active Playlist Name = %s", active_details.name); + debug( "Active Playlist path = %s", active_details.path); + debug( "Active Playlist icon path = %s", active_details.icon_path); + debug(" \n \n "); + } + + public bool connected() { return (this.player != null && this.mpris2_root != null); -- cgit v1.2.3 From bc927c2284c55ca8a30146ae905a76aa08f26fa1 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 20 Dec 2010 16:55:31 +0000 Subject: implemented suggested optional playlist mechanism --- src/mpris2-controller.vala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/mpris2-controller.vala') diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 58a1906..4990b38 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -102,9 +102,10 @@ public class Mpris2Controller : GLib.Object public bool playlist_support() { - // awaiting spec updates - // return this.mpris2_root.HasPlaylists; - return true; + if (this.playlists == null) return false; + uint32? count = this.playlists.PlaylistCount; + if ( count == null || count <= 0 ) return false; + return true; } private bool ensure_correct_playback_status(){ -- cgit v1.2.3 From c8c7681e7b9e2995d29fa58c931aa09e451c4fee Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 20 Dec 2010 18:02:50 +0000 Subject: playlists working --- src/mpris2-controller.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mpris2-controller.vala') diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 4990b38..35dc4e4 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -100,7 +100,7 @@ public class Mpris2Controller : GLib.Object } } - public bool playlist_support() + public bool playlists_support_exist() { if (this.playlists == null) return false; uint32? count = this.playlists.PlaylistCount; -- cgit v1.2.3 From 4843ae15f1ce4111c03b0fc24f5a8989d0619697 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 21 Dec 2010 14:53:56 +0000 Subject: playlists ready to go into trunk --- src/mpris2-controller.vala | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) (limited to 'src/mpris2-controller.vala') diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala index 35dc4e4..5f98541 100644 --- a/src/mpris2-controller.vala +++ b/src/mpris2-controller.vala @@ -97,6 +97,7 @@ public class Mpris2Controller : GLib.Object Variant? playlist_v = changed_properties.lookup("ActivePlaylist"); if ( playlist_v != null ){ this.fetch_active_playlist(); + //Timeout.add ( 200, fetch_active_playlist ); } } @@ -154,6 +155,7 @@ public class Mpris2Controller : GLib.Object this.owner.custom_items[PlayerController.widget_order.METADATA].update(cleaned_metadata, MetadataMenuitem.attributes_format()); this.fetch_playlists(); + this.fetch_active_playlist(); } public void transport_update(TransportMenuitem.action command) @@ -172,10 +174,8 @@ public class Mpris2Controller : GLib.Object public void fetch_playlists() { - if (this.playlists == null){ - warning("Playlists object is null"); - return; - } + if (this.playlists == null) return; + PlaylistDetails[] current_playlists = this.playlists.GetPlaylists(0, 10, "Alphabetical", @@ -184,30 +184,17 @@ public class Mpris2Controller : GLib.Object 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(" \n \n "); - debug( "Playlist Name = %s", detail.name); - debug( "Playlist path = %s", detail.path); - debug( "Playlist icon path = %s", detail.icon_path); - debug(" \n \n "); - }*/ } + return; } - public void fetch_active_playlist() + private void fetch_active_playlist() { - if (this.playlists == null && this.playlists.ActivePlaylist.valid == true){ + if (this.playlists == null && this.playlists.ActivePlaylist.valid == false){ warning("Playlists object is null or we don't have an active playlist"); - return; } PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem; playlists_item.update_active_playlist ( this.playlists.ActivePlaylist.details ); - /*debug(" \n \n "); - debug( "Active Playlist Name = %s", active_details.name); - debug( "Active Playlist path = %s", active_details.path); - debug( "Active Playlist icon path = %s", active_details.icon_path); - debug(" \n \n "); - */ } -- cgit v1.2.3