Add MPRIS media control notification

Authored by mtijink on Dec 11 2017, 11:01 AM.

Description

Add MPRIS media control notification

Summary:
BUG: 337485

Adds a notification to show and control mpris players. It shows the title, artist etc. (so depends on D9083, but can easily be adapted to work without it, but that leads to less features).

The notification appears as soon as one of your connected devices plays music. If multiple devices/players are playing, it shows the information and controls for only one of these. If it stops playing, it tries to switch to another playing device/player. If those do not exist, it shows the same player, but allows starting it again.

Dismissing the notification is only possible if the showed player is paused (as effect, only when all players are paused). It automatically closes if the device or player disappears or disconnects and no other players are playing. I think this behaviour is intuitive, other native android music players have similar behaviour.

About the implementation: there are two parts to this: the notification and the media session control API. The first shows the notification and its controls. The second allows lock screen controls on older Android versions and control using e.g. headphone buttons. Since nearly all code is shared between the two parts, and the rest is mostly straightforward, I put them in the same diff.

Test Plan:
Tested on Android Nougat 7.1 (shows the notification with buttons, as expected; no lock screen controls, as expected) and Android Gingerbread 2.3 (shows a notification without buttons, lock screen controls work, so as expected).

I am not able to test with multiple desktops, so testing that would be appreciated.

Disabling buttons when not available should work, but all players I tested always allowed next/previous/play/pause.

Reviewers: KDE Connect, nicolasfella

Reviewed By: KDE Connect, nicolasfella

Subscribers: apol, albertvaka, nicolasfella

Tags: KDE Connect

Maniphest Tasks: T6512

Differential Revision: https://phabricator.kde.org/D9266

Details

Committed
mtijinkFeb 24 2018, 4:01 PM
Reviewer
KDE Connect
Differential Revision
D9266: Add MPRIS media control notification
Parents
R225:0d00b8aa4ac3: Add album cover art support.
Branches
Unknown
Tags
Unknown