aboutsummaryrefslogtreecommitdiff
path: root/src/mpris-bridge.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/mpris-bridge.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/mpris-bridge.vala')
-rw-r--r--src/mpris-bridge.vala60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/mpris-bridge.vala b/src/mpris-bridge.vala
new file mode 100644
index 0000000..682069c
--- /dev/null
+++ b/src/mpris-bridge.vala
@@ -0,0 +1,60 @@
+public class MprisBridge : GLib.Object
+{
+ private MprisController mpris1_controller;
+ private Mpris2Controller mpris2_controller;
+ private enum mode{
+ MPRIS_1,
+ MPRIS_2
+ }
+ private mode mode_in_use;
+
+ public MprisBridge(PlayerController ctrl)
+ {
+ this.mpris2_controller == new Mpris2Controller(ctrl);
+ if(this.mpris2_controller.was_successfull() == true){
+ mode_in_use == mode.MPRIS_2;
+ this.mpris1_controller == null;
+ this.mpris2_controller.initial_update();
+ }
+ else{
+ delete this.mpris2_controller;
+ this.mpris2_controller == null;
+ mode_in_use == mode.MPRIS_1;
+ this.mpris1_controller = new Mpris1Controller(ctrl);
+ }
+ }
+
+ // The handling of both mpris controllers can be abstracted further
+ // once the mpris2 is implemented. This will allow for one instance
+ // variable to point at the active controller. For now handle both ...
+ public bool connected()
+ {
+ if(this.mode_in_use == mode.MPRIS_1){
+ return this.mpris1_controller.connected();
+ }
+ else if(this.mode_in_use == mode.MPRIS_2){
+ return this.mpris2_controller.connected();
+ }
+ return false;
+ }
+
+ public void transport_update(TransportMenuitem.action update)
+ {
+ if(this.mode_in_use == mode.MPRIS_1){
+ this.mpris1_controller.transport_event(update);
+ }
+ else if(this.mode_in_use == mode.MPRIS_2){
+ this.mpris2_controller.transport_event(update);
+ }
+ }
+
+ public void set_track_position(double pos)
+ {
+ if(this.mode_in_use == mode.MPRIS_1){
+ this.mpris1_controller.set_position(pos);
+ }
+ else if(this.mode_in_use == mode.MPRIS_2){
+ this.mpris2_controller.set_position(pos);
+ }
+ }
+} \ No newline at end of file