aboutsummaryrefslogtreecommitdiff
path: root/src/mpris2-controller.vala
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-08-12 13:21:57 +0100
committerConor Curran <conor.curran@canonical.com>2010-08-12 13:21:57 +0100
commit72ffb2c3c096cf0e7ece12c93bfeff5b651fed13 (patch)
tree908307c96ede45783599351124f03a464fb844fc /src/mpris2-controller.vala
parent44d47d0c4d334ba3cd2b8d9bd34893ba8c3dedf9 (diff)
downloadayatana-indicator-sound-72ffb2c3c096cf0e7ece12c93bfeff5b651fed13.tar.gz
ayatana-indicator-sound-72ffb2c3c096cf0e7ece12c93bfeff5b651fed13.tar.bz2
ayatana-indicator-sound-72ffb2c3c096cf0e7ece12c93bfeff5b651fed13.zip
abstracted the mpris handling to accomodate the messy integration issues
Diffstat (limited to 'src/mpris2-controller.vala')
-rw-r--r--src/mpris2-controller.vala44
1 files changed, 30 insertions, 14 deletions
diff --git a/src/mpris2-controller.vala b/src/mpris2-controller.vala
index 20cfc9e..6c1b71a 100644
--- a/src/mpris2-controller.vala
+++ b/src/mpris2-controller.vala
@@ -58,30 +58,46 @@ public class Mpris2Controller : GLib.Object
public Mpris2Controller(PlayerController ctrl)
{
- Object(owner: ctrl);
+ Object(owner: ctrl);
+ this.mpris2_root = null;
+ this.mpris2_player = null;
}
construct{
try {
- debug("going to create this mpris 2 controller");
+ debug("Going to try and create an mpris 2 controller");
this.connection = DBus.Bus.get (DBus.BusType.SESSION);
} catch (Error e) {
error("Problems connecting to the session bus - %s", e.message);
- }
- this.mpris2_root = this.connection.get_object ("org.mpris.mediaplayers.".concat(this.owner.name.down()),
- "/org/mpris/MediaPlayer",
- "org.mpris.MediaPlayer");
-
- this.mpris2_player = (MprisPlayer)this.connection.get_object ("org.mpris.mediaplayers.".concat(this.owner.name.down()) ,
- "/org/mpris/MediaPlayer/Player",
- "org.mpris.MediaPlayer.Player");
- this.mpris2_player.TrackChanged += onTrackChanged;
- this.mpris2_player.StatusChanged += onStatusChanged;
- initial_update();
+ }
+
+ try {
+ this.mpris2_root = this.connection.get_object ("org.mpris.mediaplayers.".concat(this.owner.name.down()),
+ "/org/mpris/MediaPlayer",
+ "org.mpris.MediaPlayer");
+ this.mpris2_player = (MprisPlayer)this.connection.get_object ("org.mpris.mediaplayers.".concat(this.owner.name.down()) ,
+ "/org/mpris/MediaPlayer/Player",
+ "org.mpris.MediaPlayer.Player");
+ }
+ catch(Error e){
+ error("Problems connecting to
+ }
+ }
+
+ public bool was_successfull(){
+ if(this.mpris2_root == null ||
+ this.mpris2_player == null)
+ {
+ return false;
+ }
+ return true;
}
- private void initial_update()
+ public void initial_update()
{
+ this.mpris2_player.TrackChanged += onTrackChanged;
+ this.mpris2_player.StatusChanged += onStatusChanged;
+
bool r = (bool)this.mpris2_player.Status.Shuffle_State;
int32 p = (int32)this.mpris2_player.Status.Playback_State;