Implement Seek() and Seeked()
Needs ReviewPublic

Authored by mokhtari on Jun 25 2018, 11:13 AM.

Details

Reviewers
broulik
Summary

Implementing Seek() is useful both for short seeking (+/-10s) and for
positioning, since the kde connect daemon implements setPosition() from
the android client via Seek().

Also, emit the Seeked() signal, for better synchronization.

Test Plan

TODO

Diff Detail

Repository
R856 Plasma Browser Integration
Lint
Lint Skipped
Unit
Unit Tests Skipped
mokhtari created this revision.Jun 25 2018, 11:13 AM
Restricted Application added a project: Plasma. · View Herald TranscriptJun 25 2018, 11:13 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
mokhtari requested review of this revision.Jun 25 2018, 11:13 AM
nicolasfella added a subscriber: nicolasfella.

+1, setting the position for e.g. Youtube now works from KDE Connect

Thanks for your patch! There's a minor issue but other than that it's good.
Can you also verify this doesn't cause a loop when using Plasma's media controller applet?

extension/content-script.js
177

The seekable property isn't an int but a TimeRanges object that tells you which portions of the player are seekable so this will never be false

[1] https://www.w3schools.com/tags/av_prop_seekable.asp

host/mprisplugin.cpp
205

Can't you just do emit Seeked(position)?

mokhtari updated this revision to Diff 36854.Jun 28 2018, 7:13 PM

Fixed seekable check.

Regarding loops with the Media Player widget, I haven't noticed any (using KDE Neon, 5.13.1). What test would catch this?

extension/content-script.js
177

Good catch. I uploaded a fix for this.

host/mprisplugin.cpp
205

MPrisPlugin doesn't define Seeked, so no. But it's fine with me if you think adding it to the parent and using the signal auto-relaying would be better.

Regarding macros vs. keywords, I just figured macros would be more compatible, but it could be switched to using emit as well.

broulik added inline comments.Jun 29 2018, 6:26 AM
extension/content-script.js
177

Please avoid negating a longer statement, this makes the code hard to understand at a glance:

if (activePlayer.seekable.length === 0)
host/mprisplugin.cpp
205

Doesn't it work if you define the signal in mprisplugin.h and emit there? The generated DBus code from the XML should auto-relay them. Agreed, it's somewhat magic.

mokhtari updated this revision to Diff 36902.Jun 29 2018, 7:27 PM

Clean things up a bit:

  • use signal auto-relaying to clean up mprisplugin logic
  • use more readable test in content-script.js
mokhtari marked 3 inline comments as done.Jun 29 2018, 7:29 PM
mokhtari added inline comments.
extension/content-script.js
177

Good point. Fixed.

mokhtari marked an inline comment as done.Jun 29 2018, 7:30 PM