aboutsummaryrefslogtreecommitdiff
path: root/src/mpris-controller.vala
diff options
context:
space:
mode:
authorSebastien Bacher <seb128@ubuntu.com>2010-07-08 19:30:24 +0200
committerSebastien Bacher <seb128@ubuntu.com>2010-07-08 19:30:24 +0200
commit964106d9c8c140d9c27a22aca8078dfdab57c5e9 (patch)
treee17769a890bb9dc2b337b3fad529fe7fec6cabf4 /src/mpris-controller.vala
parent26d4014fcf17ab3735a3045b9b3900e27a4a467b (diff)
parentb0a09afe59a904ce4b4e90e58d933ad1f0b036d9 (diff)
downloadayatana-indicator-sound-964106d9c8c140d9c27a22aca8078dfdab57c5e9.tar.gz
ayatana-indicator-sound-964106d9c8c140d9c27a22aca8078dfdab57c5e9.tar.bz2
ayatana-indicator-sound-964106d9c8c140d9c27a22aca8078dfdab57c5e9.zip
Import upstream version 0.3.5
Diffstat (limited to 'src/mpris-controller.vala')
-rw-r--r--src/mpris-controller.vala41
1 files changed, 30 insertions, 11 deletions
diff --git a/src/mpris-controller.vala b/src/mpris-controller.vala
index beaf02c..2194d44 100644
--- a/src/mpris-controller.vala
+++ b/src/mpris-controller.vala
@@ -27,9 +27,9 @@ public class MprisController : GLib.Object
private PlayerController controller;
struct status {
public int32 playback;
- public int32 shuffle;
- public int32 repeat;
- public int32 endless;
+ //public int32 shuffle; // Not used just yet
+ //public int32 repeat;
+ //public int32 endless;
}
public MprisController(string name, PlayerController controller, string mpris_interface="org.freedesktop.MediaPlayer"){
@@ -65,16 +65,35 @@ public class MprisController : GLib.Object
* TRUE => Playing
* FALSE => Paused
**/
- public void toggle_playback(bool state)
+ public void transport_event(TransportMenuitem.action command)
{
- if(state == true){
- debug("about to play");
- this.mpris_player.Play();
+ debug("transport_event input = %i", (int)command);
+ if(command == TransportMenuitem.action.PLAY_PAUSE){
+ status st = this.mpris_player.GetStatus();
+ bool play_state = st.playback == 1;
+ debug("toggle_playback - initial play state %i", (int)play_state);
+ bool new_play_state = !play_state;
+ debug("toggle_playback - new play state %i", (int)new_play_state);
+ if(new_play_state == true){
+ debug("about to play");
+ this.mpris_player.Play();
+ }
+ else{
+ debug("about to pause");
+ this.mpris_player.Pause();
+ }
}
- else{
- debug("about to pause");
- this.mpris_player.Pause();
- }
+ else if(command == TransportMenuitem.action.PREVIOUS){
+ this.mpris_player.previous();
+ }
+ else if(command == TransportMenuitem.action.NEXT){
+ this.mpris_player.next();
+ }
+ }
+
+ public bool connected()
+ {
+ return (this.mpris_player != null);
}
private void onStatusChange(dynamic DBus.Object mpris_client, status st)