INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: [Request] MPRIS D-Bus Interface Support  (Read 7545 times)

Awesome Donkey

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 7804
  • Autumn shade...
[Request] MPRIS D-Bus Interface Support
« on: April 13, 2016, 06:09:26 pm »

https://specifications.freedesktop.org/mpris-spec/latest/

There's multiple benefits to supporting MPRIS in MC, including...

- We can have integrated media controls in the desktop environment, e.g. GNOME 3.20. Probably Unity too, will need to look at that more.
- We can add additional desktop actions (Play/Pause, Stop, Previous, Next) to the .desktop file which will work in GNOME, Unity, Cinnamon, etc. so controlling MC while minimized in the launcher is possible.

Here's an example .desktop file with MPRIS desktop actions for controlling MC, which I'm assuming org.mpris.MediaPlayer2.mediacenter21 is being used here;

Code: [Select]
[Desktop Entry]
Type=Application
Name=Media Center 21
Comment=JRiver Media Center 21
Icon=/usr/lib/jriver/Media Center 21/Data/Default Art/Logo.png
Categories=AudioVideo;Audio;Player;
Exec=/usr/bin/mediacenter21 %F
MimeType=application/mjr;application/ogg;application/ram;application/sdp;application/smil;application/smil+xml;application/vnd.apple.mpegurl;application/vnd.ms-wpl;application/vnd.rn-realmedia;application/x-extension-m4a;application/x-extension-mp4;application/x-flac;application/x-flash-video;application/x-matroska;application/x-netshow-channel;application/x-ogg;application/x-quicktime-media-link;application/x-quicktimeplayer;application/x-shorten;application/x-smil;application/xspf+xml;audio/3gpp;audio/ac3;audio/AMR;audio/AMR-WB;audio/basic;audio/flac;audio/midi;audio/mp2;audio/mp4;audio/mpeg;audio/mpegurl;audio/ogg;audio/prs.sid;audio/vnd.rn-realaudio;audio/x-aiff;audio/x-ape;audio/x-flac;audio/x-gsm;audio/x-it;audio/x-m4a;audio/x-matroska;audio/x-mod;audio/x-mp3;audio/x-mpeg;audio/x-mpegurl;audio/x-ms-asf;audio/x-ms-asx;audio/x-ms-wax;audio/x-ms-wma;audio/x-musepack;audio/x-pn-aiff;audio/x-pn-au;audio/x-pn-realaudio;audio/x-pn-realaudio-plugin;audio/x-pn-wav;audio/x-pn-windows-acm;audio/x-realaudio;audio/x-real-audio;audio/x-s3m;audio/x-sbc;audio/x-scpls;audio/x-speex;audio/x-stm;audio/x-tta;audio/x-wav;audio/x-wavpack;audio/x-vorbis;audio/x-vorbis+ogg;audio/x-xm;image/vnd.rn-realpix;image/x-pict;misc/ultravox;text/google-video-pointer;text/x-google-video-pointer;video/3gp;video/3gpp;video/dv;video/divx;video/fli;video/flv;video/mp2t;video/mp4;video/mp4v-es;video/mpeg;video/msvideo;video/ogg;video/quicktime;video/vivo;video/vnd.divx;video/vnd.mpegurl;video/vnd.rn-realvideo;video/vnd.vivo;video/webm;video/x-anim;video/x-avi;video/x-flc;video/x-fli;video/x-flic;video/x-flv;video/x-m4v;video/x-matroska;video/x-mpeg;video/x-mpeg2;video/x-ms-asf;video/x-ms-asx;video/x-msvideo;video/x-ms-wm;video/x-ms-wmv;video/x-ms-wmx;video/x-ms-wvx;video/x-nsv;video/x-ogm+ogg;video/x-theora+ogg;video/x-totem-stream;x-content/video-dvd;x-content/video-vcd;x-content/video-svcd;x-scheme-handler/pnm;x-scheme-handler/mms;x-scheme-handler/net;x-scheme-handler/rtp;x-scheme-handler/rtmp;x-scheme-handler/rtsp;x-scheme-handler/mmsh;x-scheme-handler/uvox;x-scheme-handler/icy;x-scheme-handler/icyx;
Terminal=false
StartupWMClass=Media_Center_21
StartupNotify=true
Actions=PlayPause;Stop;Next;Previous;Separator;Register;

[Desktop Action PlayPause]
Name=Play/Pause
Exec=dbus-send --print-reply --dest=org.mpris.MediaPlayer2.mediacenter21 /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause

[Desktop Action Stop]
Name=Stop
Exec=dbus-send --print-reply --dest=org.mpris.MediaPlayer2.mediacenter21 /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop

[Desktop Action Next]
Name=Next
Exec=dbus-send --print-reply --dest=org.mpris.MediaPlayer2.mediacenter21 /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next

[Desktop Action Previous]
Name=Previous
Exec=dbus-send --print-reply --dest=org.mpris.MediaPlayer2.mediacenter21 /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous

[Desktop Action Separator]
Name=______________________________________
Exec=

[Desktop Action Register]
Name=Install License
Exec=/usr/bin/mediacenter21 %f /RestoreFromFile

Yeah, I added a separator between the controls and the install license action to help prevent accidental clicks. If supported that *should* work rather well. It's been discussed in multiple topics including here and here.

Thoughts? +1's? Anything?!?
Logged
I don't work for JRiver... I help keep the forums safe from "male enhancements" and other sources of sketchy pharmaceuticals.

Windows 11 24H2 Update 64-bit + Ubuntu 24.10 Oracular Oriole 64-bit | Windows 11 24H2 Update 64-bit (Intel N305 Fanless NUC 16GB RAM/500GB M.2 NVMe SSD)
JRiver Media Center 33 (Windows + Linux) | iFi ZEN DAC 3 | JBL 306P MkII Studio Monitors | Audio-Technica ATH-M50x Headphones

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: [Request] MPRIS D-Bus Interface Support
« Reply #1 on: April 13, 2016, 07:06:25 pm »

+1 - it's the standard and will integrate directly with the Gnome panel/notification system. And it should work for Unity and Cinnamon too.  Having that level of integration with Gnome/Unity/Cinnamon would be fantastic and would put MC on an equal footing with most other Linux media players (most of which have some level of integration already).

It would also obsolete my hacky dbus track-change notifier script, which would be nice  ;D
Logged

Awesome Donkey

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 7804
  • Autumn shade...
Re: [Request] MPRIS D-Bus Interface Support
« Reply #2 on: April 13, 2016, 07:34:10 pm »

I haven't done too much searching (lack of time, heh) but there's a function to display album art of the currently playing track in the panel with MPRIS, right?

P.S. I might have to release my Arc Theme and Adwaita ModernCards-forked alpha skins and make a Mint/Cinnamon version. :D
Logged
I don't work for JRiver... I help keep the forums safe from "male enhancements" and other sources of sketchy pharmaceuticals.

Windows 11 24H2 Update 64-bit + Ubuntu 24.10 Oracular Oriole 64-bit | Windows 11 24H2 Update 64-bit (Intel N305 Fanless NUC 16GB RAM/500GB M.2 NVMe SSD)
JRiver Media Center 33 (Windows + Linux) | iFi ZEN DAC 3 | JBL 306P MkII Studio Monitors | Audio-Technica ATH-M50x Headphones

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5234
  • "Linux Merit Badge" Recipient
Re: [Request] MPRIS D-Bus Interface Support
« Reply #3 on: April 13, 2016, 07:51:50 pm »

I haven't done too much searching (lack of time, heh) but there's a function to display album art of the currently playing track in the panel with MPRIS, right?

P.S. I might have to release my Arc Theme and Adwaita ModernCards-forked alpha skins and make a Mint/Cinnamon version. :D

The MPRIS panel integration functionality is new in Gnome 3.20, but I tested a few other players and they show cover art, provide controls, and notifications in the panel.  Here's how the integration looks with rhythmbox:
Logged

Awesome Donkey

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 7804
  • Autumn shade...
Re: [Request] MPRIS D-Bus Interface Support
« Reply #4 on: April 13, 2016, 08:01:27 pm »

Looking pretty good there. :D

Also this *should* also work for Xfce and KDE too, according to what little I've read. Not sure about MATE or LXDE.
Logged
I don't work for JRiver... I help keep the forums safe from "male enhancements" and other sources of sketchy pharmaceuticals.

Windows 11 24H2 Update 64-bit + Ubuntu 24.10 Oracular Oriole 64-bit | Windows 11 24H2 Update 64-bit (Intel N305 Fanless NUC 16GB RAM/500GB M.2 NVMe SSD)
JRiver Media Center 33 (Windows + Linux) | iFi ZEN DAC 3 | JBL 306P MkII Studio Monitors | Audio-Technica ATH-M50x Headphones

Rizlaw

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 283
Re: [Request] MPRIS D-Bus Interface Support
« Reply #5 on: April 16, 2016, 07:01:40 pm »

+1

I would add that application called "Screenlets" (https://launchpad.net/screenlets) which is in the Debian repositories (and I'm sure Arch as well), has a "Now Playing" applet which works nicely with mpris/D-bus. I posted about this a few months ago in this forum with a picture here: http://yabb.jriver.com/interact/index.php?topic=101351.0
Logged
Ubuntu Gnome 20.04 LTS

Rizlaw

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 283
Re: [Request] MPRIS D-Bus Interface Support
« Reply #6 on: April 16, 2016, 08:00:01 pm »

https://specifications.freedesktop.org/mpris-spec/latest/

There's multiple benefits to supporting MPRIS in MC, including...

- We can have integrated media controls in the desktop environment, e.g. GNOME 3.20. Probably Unity too, will need to look at that more.
- We can add additional desktop actions (Play/Pause, Stop, Previous, Next) to the .desktop file which will work in GNOME, Unity, Cinnamon, etc. so controlling MC while minimized in the launcher is possible.

Here's an example .desktop file with MPRIS desktop actions for controlling MC, which I'm assuming org.mpris.MediaPlayer2.mediacenter21 is being used here;

Code: [Select]
[Desktop Entry]
Type=Application
Name=Media Center 21
Comment=JRiver Media Center 21
Icon=/usr/lib/jriver/Media Center 21/Data/Default Art/Logo.png
Categories=AudioVideo;Audio;Player;
Exec=/usr/bin/mediacenter21 %F
MimeType=application/mjr;application/ogg;application/ram;application/sdp;application/smil;application/smil+xml;application/vnd.apple.mpegurl;application/vnd.ms-wpl;application/vnd.rn-realmedia;application/x-extension-m4a;application/x-extension-mp4;application/x-flac;application/x-flash-video;application/x-matroska;application/x-netshow-channel;application/x-ogg;application/x-quicktime-media-link;application/x-quicktimeplayer;application/x-shorten;application/x-smil;application/xspf+xml;audio/3gpp;audio/ac3;audio/AMR;audio/AMR-WB;audio/basic;audio/flac;audio/midi;audio/mp2;audio/mp4;audio/mpeg;audio/mpegurl;audio/ogg;audio/prs.sid;audio/vnd.rn-realaudio;audio/x-aiff;audio/x-ape;audio/x-flac;audio/x-gsm;audio/x-it;audio/x-m4a;audio/x-matroska;audio/x-mod;audio/x-mp3;audio/x-mpeg;audio/x-mpegurl;audio/x-ms-asf;audio/x-ms-asx;audio/x-ms-wax;audio/x-ms-wma;audio/x-musepack;audio/x-pn-aiff;audio/x-pn-au;audio/x-pn-realaudio;audio/x-pn-realaudio-plugin;audio/x-pn-wav;audio/x-pn-windows-acm;audio/x-realaudio;audio/x-real-audio;audio/x-s3m;audio/x-sbc;audio/x-scpls;audio/x-speex;audio/x-stm;audio/x-tta;audio/x-wav;audio/x-wavpack;audio/x-vorbis;audio/x-vorbis+ogg;audio/x-xm;image/vnd.rn-realpix;image/x-pict;misc/ultravox;text/google-video-pointer;text/x-google-video-pointer;video/3gp;video/3gpp;video/dv;video/divx;video/fli;video/flv;video/mp2t;video/mp4;video/mp4v-es;video/mpeg;video/msvideo;video/ogg;video/quicktime;video/vivo;video/vnd.divx;video/vnd.mpegurl;video/vnd.rn-realvideo;video/vnd.vivo;video/webm;video/x-anim;video/x-avi;video/x-flc;video/x-fli;video/x-flic;video/x-flv;video/x-m4v;video/x-matroska;video/x-mpeg;video/x-mpeg2;video/x-ms-asf;video/x-ms-asx;video/x-msvideo;video/x-ms-wm;video/x-ms-wmv;video/x-ms-wmx;video/x-ms-wvx;video/x-nsv;video/x-ogm+ogg;video/x-theora+ogg;video/x-totem-stream;x-content/video-dvd;x-content/video-vcd;x-content/video-svcd;x-scheme-handler/pnm;x-scheme-handler/mms;x-scheme-handler/net;x-scheme-handler/rtp;x-scheme-handler/rtmp;x-scheme-handler/rtsp;x-scheme-handler/mmsh;x-scheme-handler/uvox;x-scheme-handler/icy;x-scheme-handler/icyx;
Terminal=false
StartupWMClass=Media_Center_21
StartupNotify=true
Actions=PlayPause;Stop;Next;Previous;Separator;Register;

[Desktop Action PlayPause]
Name=Play/Pause
Exec=dbus-send --print-reply --dest=org.mpris.MediaPlayer2.mediacenter21 /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause

[Desktop Action Stop]
Name=Stop
Exec=dbus-send --print-reply --dest=org.mpris.MediaPlayer2.mediacenter21 /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop

[Desktop Action Next]
Name=Next
Exec=dbus-send --print-reply --dest=org.mpris.MediaPlayer2.mediacenter21 /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next

[Desktop Action Previous]
Name=Previous
Exec=dbus-send --print-reply --dest=org.mpris.MediaPlayer2.mediacenter21 /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous

[Desktop Action Separator]
Name=______________________________________
Exec=

[Desktop Action Register]
Name=Install License
Exec=/usr/bin/mediacenter21 %f /RestoreFromFile

Yeah, I added a separator between the controls and the install license action to help prevent accidental clicks. If supported that *should* work rather well. It's been discussed in multiple topics including here and here.

Thoughts? +1's? Anything?!?

Awesome Donkey,

Is this code intended to work in MC21 build 70 now? I tried it by copying the code above to a new file which I initially named "testmc21.desktop". I made the file executable. When I clicked the file to run it, the file auto-magically renamed itself to mediacenter21, displayed the media center icon and ran. It opened MC21, created a duplicate MediaCenter icon in the Unity Panel identical to the existing MediaCenter icon and had the same right click controls (Install license, Media Center 21, Unlock from launcher). There were no "play/pause, stop, forward, backward" controls on the second icon. I did not copy the "testmc21.desktop" file to the .local/share/applications folder when I ran the test. I'm not sure that had anything to do with the result.

I also have the "Screenlets" NowPlaying applet running and set up for Mpris/D-Bus for two other Linux media players (Guayadeque and Quod Liebet) If your code were working I would expect to see the NowPlaying applet fade in on my desktop and show the currently playing cover art from MC21, plus transport controls.

I hope this feedback helps.
Logged
Ubuntu Gnome 20.04 LTS

Awesome Donkey

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 7804
  • Autumn shade...
Re: [Request] MPRIS D-Bus Interface Support
« Reply #7 on: April 16, 2016, 08:12:53 pm »

No, it doesn't work as MC lacks MPRIS hence the request. It was just an example that could be used.
Logged
I don't work for JRiver... I help keep the forums safe from "male enhancements" and other sources of sketchy pharmaceuticals.

Windows 11 24H2 Update 64-bit + Ubuntu 24.10 Oracular Oriole 64-bit | Windows 11 24H2 Update 64-bit (Intel N305 Fanless NUC 16GB RAM/500GB M.2 NVMe SSD)
JRiver Media Center 33 (Windows + Linux) | iFi ZEN DAC 3 | JBL 306P MkII Studio Monitors | Audio-Technica ATH-M50x Headphones

Mike Noe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 792
Re: [Request] MPRIS D-Bus Interface Support
« Reply #8 on: April 19, 2016, 09:45:36 am »

Yep, good idea, +1.  I've implemented with an app as a go-between on Plasma5 and it works.....for one zone.....or the current zone.

I can set up a unique service for each zone, ie:
Code: [Select]
org.mpris.MediaPlayer2.mcwsRemote.instance0
org.mpris.MediaPlayer2.mcwsRemote.instance10000
org.mpris.MediaPlayer2.mcwsRemote.instance10001
.
.

But when defining the object/path (/org/mpris/MediaPlayer2 or /org/mpris/MediaPlayer2.Player) with a MC PlaybackZone, I can't seem to make it unique so that a zone player object in my app is associated with a different object/path in each unique service.

The work around I've used so far is mucho-hacky, essentially every time a zone command is issued, I'm re-registering the mpris object/path with the destination zone player object in my app.

Otherwise, there has to be some way for the mpris plasmoid (or launcher, whatever) to specify a zone other than "current" zone.

[edit] btw, on Plasma5, the systray plasmoid supplied handles multiple players (which can be MC zones) and all playback commands without having the .desktop file explicit actions.
Logged
openSUSE TW/Plasma5 x86_64 | Win10Pro/RX560
S.M.S.L USB-DAC => Transcendent GG Pre (kit) => Transcendent mono OTLs (kit)
(heavily modded) Hammer Dynamics Super-12s (kit)
(optionally) VonSchweikert VR8s

Mike Noe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 792
Re: [Request] MPRIS D-Bus Interface Support
« Reply #9 on: April 23, 2016, 05:44:27 am »

So I messed around with this a little to try to remember why MPRIS was flaky....

Basically, each process that registers to support the mpris service is limited to one object/path (/org/mpris/MediaPlayer2) to advertise interfaces (MediaPlayer2, PlayerInterface, TrackList, Playlists).  Essentially, the player process gets one object/path on the service to advertise the interfaces.

Of course, MC can have any number of players (zones) in the same process.  So, an MPRIS client can see the zones (each registered as a service) but unless each zone can also provide a seperate object/path and the client can handle the different object/paths, supporting a multi-zone MC player/server will be hit or miss.  The hack is to provide an interface to the user to choose which zone is the MPRIS default.

However, if a separate process is created for each zone and each process registers a unique mpris service name (per the spec), then the generic MPRIS clients can offer the choice of player(zone) without being limited by the single object/path (/org/mpris/MediaPlayer2) per service.
Logged
openSUSE TW/Plasma5 x86_64 | Win10Pro/RX560
S.M.S.L USB-DAC => Transcendent GG Pre (kit) => Transcendent mono OTLs (kit)
(heavily modded) Hammer Dynamics Super-12s (kit)
(optionally) VonSchweikert VR8s
Pages: [1]   Go Up