Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache the position property #102

Closed
acrisci opened this issue Oct 14, 2018 · 2 comments
Closed

Cache the position property #102

acrisci opened this issue Oct 14, 2018 · 2 comments
Milestone

Comments

@acrisci
Copy link
Member

acrisci commented Oct 14, 2018

When position is gotten, right now we do a dbus call to get the current position from the player.

Instead, calculate the current position based on previous status changes and clock monotonic time.

Maybe at some point in the future consider rate changes too.

This might improve position calculation with spotify a bit (it's totally broken now) although we still don't get a "seeked" event so it will still be wrong.

Add a playerctl_player_get_position() function to get the old behavior of hitting the dbus interface since I'm not confident we can rely on players to give the correct events to make this work correctly all the time.

In fact I'm not totally confident this will work at all, but it will be interesting to try. The interface specification seems to hint that we can do it.

@acrisci acrisci added this to the 1.0.0 milestone Oct 14, 2018
@acrisci
Copy link
Member Author

acrisci commented Oct 14, 2018

The algorithm goes like this:

Keep cached-position and cached-position-monotonic.

When play transitions to "playing", update cached-position-monotonic.

When we get the "seeked" signal, update cached-position and cached-position-monotonic.

When getting the position property,

If paused then return cached-position

If stopped return 0

if playing return elapsed time of cached-position-monotonic and monotonic time plus cached-position

@triallax
Copy link

Is there a way to disable this caching? It doesn't take into account the playback speed, and (with mpv at least) while a video is still loading from the network, it starts incrementing the position even though nothing started playing yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants