Expose presentation via MPRIS to rich remote controllers

Authored by kossebau on Mar 11 2018, 9:31 PM.


Group Reviewers

When going into presentation mode, a D-Bus object is created that
implements MPRIS spec and exposes control to the presentation.
By that any existing MPRIS controllers can be used next to the existing
direct control by Okular UI itself.
This includes e.g.

  • keyboard mediakeys (Play/Pause, Stop, Next, Previous), as handled by Plasma mpris dataengine
  • KDE Connect MPris plugin

For giving a presentation and not having to stand next to the computer
which runs Okular, one can use wireless input controllers.
Sometimes though one would like more rich remote controllers, e.g.
with a display showing notes for the current page, giving a preview
of the next/previous page, or allowing to jump to a page directly
without everyone following on the big screen the search in the pages list.
Such a rich remote controller could be done e.g. by an app for a mobile,
which then connects to Okular.
Instead of writing a custom controller app and designing a custom protocol,
another option is to use the MPRIS spec and map the concepts of the
Okular document and its pages onto the MPRIS tracklist and tracks.
After all the "media player" in MPRIS is an abstraction, and to a good
degree it is possible to make the Okular presentation mode an
instantiation of it.
While the current version 2 of MPRIS seems done rather with typical
music players or movie players in mind, a future version shall also
take presentation shows more into the design.
This initial patch already enables simple Play/Pause/Next/Previous
remote control, which is handy for remote controlling via KDE Connect.

Future patches should also implement tracklist support, so a controller
is e.g. able to show the complete list of tracks^Wpages as thumbnails.

Test Plan

Load a document, enter presentation mode and see Okular appear in the
KDE Connect Multimedia Remote Control, following commands or updating
the states.

Diff Detail

R223 Okular
No Linters Available
No Unit Test Coverage
kossebau created this revision.Mar 11 2018, 9:31 PM
Restricted Application added a project: Okular. · View Herald TranscriptMar 11 2018, 9:31 PM
kossebau requested review of this revision.Mar 11 2018, 9:31 PM

Right now trying to also get preview of the current page implemented, by storing the PixmapRequest result in a temporary file and passing that in the metadata as mpris:artUrl.
But not sure if I make it tonight, and already useful as is, so this upload for first round of feedback.

rkflx added a subscriber: rkflx.Mar 12 2018, 12:53 AM
kossebau updated this revision to Diff 29326.Mar 12 2018, 12:57 PM
  • added thumbnail support
  • fixed unregistering from DBus when presentationwidget is only closed, not deleted

Two issues yet, one in code and one possibly in Plasma:
a) the same okular process can have multiple documents open and thus run multiple presentations at the same time. The current code will only expose the first presentation to mpris. No idea yet how to handle that given MPRIS only expects one MPRIS object per D-Bus service. But then might also not be a problem for 99% of the usecases, so dp npt see this as real showstopper.

b) sometimes Plasma stuff (seems mpris dataengine mainly) misses to detect the new MPRIS D-Bus service. As KDEConnect does not have the problem and qdbusviewer also shows DBus service & object as expected, for now I suspect it is an issue in the Plasma mpris dataengine. Yet to be investigated.

kossebau updated this revision to Diff 29333.Mar 12 2018, 2:50 PM

Register objects before registering the service name, this should help Plasma
MPRIS controllers & others to use the service instantly when the name is

pino added a subscriber: pino.Mar 16 2018, 2:21 PM

Please do not restrict it to Q_OS_LINUX, as there is no Linux-only code (nor the feature is specific to Linux in any way).

In D11250#227259, @pino wrote:

Please do not restrict it to Q_OS_LINUX, as there is no Linux-only code (nor the feature is specific to Linux in any way).

Good hint, possibly was misguided by the special case for QDBusUnixFileDescriptor. But QtDBus is a required build dep unconditionally, and then what you said. Fixed in incoming update.

kossebau updated this revision to Diff 29681.Mar 16 2018, 2:36 PM
  • always create mpris service, not only with Q_OS_LINUX
  • minor code clean-ups

So far got a few comments about this being a nice idea in general, and one already about something in the code. So far all positive. Now, where are the negative ones, there must be some :)
If not or even then, I hope for some good people for some further detailed review of the code and/or feature in the next days, please :)

I know this came late in as new feature for 18.04, but still would be glad if we could manage to decide about it just in time (5 days left still until feature freeze next Thursday).

Some more motivational info about this patch:
While the current state of this feature is yet missing a lot over e.g. what is possible with https://wiki.documentfoundation.org/Impress_Remote , it still already adds value for people wanting to remote control their presentation, but who do not have a special wireless remote control input device.
Older projects like https://code.google.com/archive/p/remuco/ or (k)anyRemote also supporting Okular show there are at least some people who like to have such functionality for making use of their existing mobile device instead.

Also having this now in Okular, next to Gwenview (which already got a similar feature a few days ago), allows to keep Okular presentation feature in the loop and getting feedback from users already when working on enhancing the MPRIS spec for a future version for improved support for non-music media (see also https://community.kde.org/MPRIS#Features_for_MPRIS_3.0 for planning).

For your inspiration about the proposed feature, here another thing which gets possible this way: in a meeting everyone could have their mobile connected with KDE Connect to the presentation device running Okular, and in discussion then everybody could navigate through the current presentation thanks to KDE Connect & MPRIS :) No more need to having to tell the current presentation-doing person which slide you want to see again or pass the remote control around or stand up and take over position next to presentation device when it is your turn. Just keep leaned back in your chair with legs up and touch your mobile :)

And some note:
when testing with KDE Connect for Android, make sure to use latest version 1.8, there had been some glitches with previous/next action buttons before.

aacid added a subscriber: aacid.Mar 18 2018, 11:28 PM
aacid added inline comments.

This seems like random glue code, wouldn't this make more sense in Qt or in KF5?


Should be about right


No, you can not, file can change at any moment.


Why do you need that?


are this ugly uppercase tyied to the spec? Isn't there like a magic way in Qt to create the api from the xml spec?

kossebau added inline comments.Mar 18 2018, 11:54 PM

Possibly. Similar code working around the missing Qt feature is found across code. Actually one would expect this indeed with Qt, but the one known related bug report https://bugreports.qt.io/browse/QTBUG-48008 got for whatever reason a harsh wontfix.
Not my playing ground, so I escaped into manual workaround like found elsewhere. Will be happy to have something in Qt or KF5, but do not have resources for that.


Also during presentation? Okay. Any change signal you would recommend to catch here? Would encode some thumbnail versioning then to ensure uniquness.


To avoid creating repeated requests for the same pixmap.

Challenge I see: I need to get a thumbnail per page. To speed-up things, it will be done only for pages currently visited. But given the request is processed async, when a user switches pages while the requests are still on-going, when entering the same page multiple times multiple requests would be created, one per visit.

Is there some internal mechanism to squash such requests?


Yes, needed due to using sessionBus.registerObject(mediaPlayer2ObjectPath(), this, QDBusConnection::ExportAdaptors);, and D-Bus methods should be Uppercase and so does MPRIS.
I only know qt5_add_dbus_interface() for creating nice-Qt-style API for interfaces to be used with remote objects. For local actual implementations of interfaces I am not aware how to avoid that, the other code I saw doing MPRIS implementations did things the same way as here. Might have missed something, but done to my best knowledge.

kossebau updated this revision to Diff 29945.Mar 19 2018, 8:18 PM

extend MprisThumbnailStore to support updates of thumbnails

kossebau abandoned this revision.Feb 21 2019, 11:02 PM

No personal need anymore, and seemingly no-one else interested, thus discarding.

Restricted Application added a subscriber: okular-devel. · View Herald TranscriptFeb 21 2019, 11:02 PM