[gnome-music] Implement MediaPlayer2 interface of MPRIS



commit 0ee52b1ee1caaf9fef90dbe6709e902cc461a5cf
Author: Arnel A. Borja <kyoushuu yahoo com>
Date:   Sat Jun 22 23:10:11 2013 +0800

    Implement MediaPlayer2 interface of MPRIS
    
    https://bugzilla.gnome.org/show_bug.cgi?id=702866

 src/application.js |   62 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index fb995ab..73b3157 100644
--- a/src/application.js
+++ b/src/application.js
@@ -40,6 +40,18 @@ var AppState = {
     PLAYLIST_NEW: 5
 };
 
+const MediaPlayer2Iface = <interface name="org.mpris.MediaPlayer2">
+  <method name="Raise"/>
+  <method name="Quit"/>
+  <property name="CanQuit" type="b" access="read"/>
+  <property name="CanRaise" type="b" access="read"/>
+  <property name="HasTrackList" type="b" access="read"/>
+  <property name="Identity" type="s" access="read"/>
+  <property name="DesktopEntry" type="s" access="read"/>
+  <property name="SupportedUriSchemes" type="as" access="read"/>
+  <property name="SupportedMimeTypes" type="as" access="read"/>
+</interface>;
+
 const Application = new Lang.Class({
     Name: 'Music',
     Extends: Gtk.Application,
@@ -52,6 +64,11 @@ const Application = new Lang.Class({
         });
 
         GLib.set_application_name(_("Music"));
+
+        this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(MediaPlayer2Iface, this);
+        this._dbusImpl.export(Gio.DBus.session, '/org/mpris/MediaPlayer2');
+
+        Gio.DBus.session.own_name('org.mpris.MediaPlayer2.gnome-music', Gio.BusNameOwnerFlags.REPLACE, null, 
null);
     },
 
     _buildAppMenu: function() {
@@ -116,4 +133,49 @@ const Application = new Lang.Class({
             this.quit();
         }));
     },
+
+    /* MPRIS */
+
+    Raise: function() {
+        this._window.present();
+    },
+
+    Quit: function() {
+        this.quit();
+    },
+
+    get CanQuit() {
+        return true;
+    },
+
+    get CanRaise() {
+        return true;
+    },
+
+    get HasTrackList() {
+        return false;
+    },
+
+    get Identity() {
+        return 'Music';
+    },
+
+    get DesktopEntry() {
+        return 'gnome-music';
+    },
+
+    get SupportedUriSchemes() {
+        return [
+            'file'
+        ];
+    },
+
+    get SupportedMimeTypes() {
+        return [
+            'application/ogg',
+            'audio/x-vorbis+ogg',
+            'audio/x-flac',
+            'audio/mpeg'
+        ];
+    },
 });


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]