How to respond to play/pause/next/previous buttons on headphones?

Hello, I’m still working on the Sailfin media player, for which I’ve recently added music playback. Right now I’m using QMediaPlayer for music playback and I’ve also implemented the MPRIS DBus interfaces so the music can be controlled from lock screen. I’ve tested the implementation and it works correctly in SailfishOS from the lockscreen and KDE Plasma.

I expected the MPRIS implementation to be enough for responding to the buttons on the headset, but it does not respond to any buttons. Is there anything else that should be implemented for this to work that I haven’t?

2 Likes

You need to define media keys.

I have owned this trick from Talefish but jgibbon moved the MediaKey stuff out of the root qml file so I cannot find it on the quick.

But be aware: At the time of writing this Mpris stuff is not featured for harbour applicaions (this is why podqast has a forbidden fruits (ff) variant on openrepos). It looks like it will be allowed in some of the future releases of SFOS but not now.

2 Likes

Thank you! I’ll try to implement it as soon as possible.

As for now, I’ve implemented the DBus MPRIS interface myself using QDBus, to avoid the harbour restriction and to avoid being dependent on a Nemo library that may not work on other platforms such as the Linux Desktop or Ubuntu Touch.

1 Like

yep I am thinking about self implementing the stuff in python dbus too (who will be faster, Jolla or me?)

2 Likes

It seems that headphone buttons are handled via MPRIS now: [Release notes] Verla 4.2.0

Did you try it with your actual code? That then should work out of the box?
(oups because I have a device with the brand new 4.2.0.19 not everybody has one: Do you have a Sailfin version with audio somewhere to check this with 4.2.0?)

I’m running 4.2.0 right now without having implemented the media keys handler in QML, but with MPRIS and it works for me.

If you want to have a build of Sailfin with audio support you can either build it yourself from the latest commit on the master branch (or sent me a PM if you want to have a RPM built from master if you cannot build it yourself) or wait until later this week, because I hope to have fixed most of the regressions by then, so I can release a new version.

Does anyone have QML MprisPlayer working with a BT headset in 4.2?
I can’t get it to work. Lockscreen controls (also over MPRIS) work fine, and the headset works with the Jolla Media Player. QML MediaKey aren’t getting any events either, so i’m quite confused.