From a0fae2ec3183d1d9a651b38d0e2980c029cd7d28 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Mon, 17 Jun 2013 12:18:36 -0400 Subject: Export playback menu item --- src/media-player.vala | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/media-player.vala') diff --git a/src/media-player.vala b/src/media-player.vala index 717d135..b767268 100644 --- a/src/media-player.vala +++ b/src/media-player.vala @@ -74,6 +74,12 @@ public class MediaPlayer: Object { } } + public bool is_playing { + get { + return this.proxy != null && this.proxy.PlaybackStatus == "Playing"; + } + } + public class Track : Object { public string artist { get; construct; } public string title { get; construct; } @@ -132,6 +138,30 @@ public class MediaPlayer: Object { } } + /** + * Toggles playing status. + */ + public void play_pause () { + if (this.proxy != null) + this.proxy.PlayPause.begin (); + } + + /** + * Skips to the next track. + */ + public void next () { + if (this.proxy != null) + this.proxy.Next.begin (); + } + + /** + * Skips to the previous track. + */ + public void previous () { + if (this.proxy != null) + this.proxy.Previous.begin (); + } + DesktopAppInfo appinfo; MprisPlayer? proxy; string _dbus_name; @@ -170,8 +200,10 @@ public class MediaPlayer: Object { } void proxy_properties_changed (DBusProxy proxy, Variant changed_properties, string[] invalidated_properties) { - if (changed_properties.lookup ("PlaybackStatus", "s", null)) + if (changed_properties.lookup ("PlaybackStatus", "s", null)) { this.notify_property ("state"); + this.notify_property ("is-running"); + } var metadata = changed_properties.lookup_value ("Metadata", new VariantType ("a{sv}")); if (metadata != null) -- cgit v1.2.3