aboutsummaryrefslogtreecommitdiff
path: root/src/mpris2-controller.vala
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-12-17 16:25:04 +0000
committerConor Curran <conor.curran@canonical.com>2010-12-17 16:25:04 +0000
commit80ce8f642c251dc765267fa1b1978fec59d23c97 (patch)
tree3966c20e333cc79744fe54e4aa699a693b934efd /src/mpris2-controller.vala
parent7ea64f857b5f76cd06e01bfe49eda27c2d2da335 (diff)
parent032797fd7a92bc8a4fd979ddc12cacb0918ca73b (diff)
downloadayatana-indicator-sound-80ce8f642c251dc765267fa1b1978fec59d23c97.tar.gz
ayatana-indicator-sound-80ce8f642c251dc765267fa1b1978fec59d23c97.tar.bz2
ayatana-indicator-sound-80ce8f642c251dc765267fa1b1978fec59d23c97.zip
playlists - working nicely
Diffstat (limited to 'src/mpris2-controller.vala')
-rw-r--r--src/mpris2-controller.vala84
1 files changed, 77 insertions, 7 deletions
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index 7f14efe..58a1906 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -18,11 +18,10 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Dbusmenu;
-
[DBus (name = "org.freedesktop.DBus.Properties")]
- public interface FreeDesktopProperties : Object{
- public signal void PropertiesChanged(string source, HashTable<string, Variant?> changed_properties,
- string[] invalid);
+public interface FreeDesktopProperties : Object{
+ public signal void PropertiesChanged (string source, HashTable<string, Variant?> changed_properties,
+ string[] invalid );
}
/*
@@ -33,13 +32,14 @@ public class Mpris2Controller : GLib.Object
{
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{
@@ -50,10 +50,13 @@ public class Mpris2Controller : GLib.Object
this.player = Bus.get_proxy_sync ( BusType.SESSION,
this.owner.dbus_name,
"/org/mpris/MediaPlayer2" );
+ this.playlists = Bus.get_proxy_sync ( BusType.SESSION,
+ this.owner.dbus_name,
+ "/org/mpris/MediaPlayer2" );
this.properties_interface = Bus.get_proxy_sync ( BusType.SESSION,
"org.freedesktop.Properties.PropertiesChanged",
- "/org/mpris/MediaPlayer2" );
+ "/org/mpris/MediaPlayer2" );
this.properties_interface.PropertiesChanged.connect ( property_changed_cb );
}
catch (IOError e) {
@@ -91,8 +94,19 @@ 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 ){
+ this.fetch_active_playlist();
+ }
}
+ public bool playlist_support()
+ {
+ // awaiting spec updates
+ // return this.mpris2_root.HasPlaylists;
+ return true;
+ }
+
private bool ensure_correct_playback_status(){
debug("TEST playback status = %s", this.player.PlaybackStatus);
TransportMenuitem.state p = (TransportMenuitem.state)this.determine_play_state(this.player.PlaybackStatus);
@@ -138,6 +152,7 @@ public class Mpris2Controller : GLib.Object
GLib.HashTable<string, Value?>? 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)
@@ -154,6 +169,47 @@ 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(" \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 ");
+ }*/
+ }
+ }
+
+ public void fetch_active_playlist()
+ {
+ if (this.playlists == null && this.playlists.ActivePlaylist.valid == true){
+ 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 ");
+ */
+ }
+
+
public bool connected()
{
return (this.player != null && this.mpris2_root != null);
@@ -165,4 +221,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