aboutsummaryrefslogtreecommitdiff
path: root/src/media-player.vala
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2013-06-17 12:18:36 -0400
committerLars Uebernickel <lars.uebernickel@canonical.com>2013-06-17 12:18:36 -0400
commita0fae2ec3183d1d9a651b38d0e2980c029cd7d28 (patch)
tree985abb977dbc92724e945bb744e8022ce1593c58 /src/media-player.vala
parent9b3162f7aeb23197f6bde643a897c64bd1133986 (diff)
downloadayatana-indicator-sound-a0fae2ec3183d1d9a651b38d0e2980c029cd7d28.tar.gz
ayatana-indicator-sound-a0fae2ec3183d1d9a651b38d0e2980c029cd7d28.tar.bz2
ayatana-indicator-sound-a0fae2ec3183d1d9a651b38d0e2980c029cd7d28.zip
Export playback menu item
Diffstat (limited to 'src/media-player.vala')
-rw-r--r--src/media-player.vala34
1 files changed, 33 insertions, 1 deletions
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)