[SailfishDevel] Listening for headset media button in qt/qml

jerome levreau levreau.jerome at vostoksystem.eu
Tue May 14 14:44:06 UTC 2019


hi,
I'm trying to make my app Muuzik - an audio player from the store -
recognize bluetooth headset media button without luck.

The headset is paired and works with the default / jolla media app as
expected (prev, next, play/pause)

My app provide an mpris2 interface, registered on dbus, it work perfectly
from the phone panel (previous, play/stop, next, track info...), I also
added a listener on org.mpris.MediaPlayer2 and I'm getting callback from
other app but nothing when pressing the headset button. Guessing this is
not a mpris2 issue.

So I tried to work from qml with Permissions / Resource / MediaKey.
I can "hijack" the volumes buttons with Resource.ScaleButtons -
Qt.Key_VolumeUp/Down but nothing working with Resource.HeadsetButtons /
Qt.Key_Media*

Here some code : Don't work (but does with Resource.ScaleButtons -
Qt.Key_VolumeUp/Down):

MediaKey {
        id: mediaNext
        enabled: true
        key: Qt.Key_MediaNext
        onPressed : {
            console.log("expect Key_MediaNext")
        }
    }
Permissions {
        enabled: app.applicationActive
        autoRelease: true
        applicationClass: "player"

        Resource {
            id: headsetAccessResource
            type: Resource.HeadsetButtons
            optional: false
        }
}

What next solution would you recommend ?

Thank,
Jerome.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20190514/6ace7731/attachment.html>


More information about the Devel mailing list