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

Seeking fixes and related improvements #17

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

groszdaniel
Copy link

This fixes two seeking bugs, and adds several related improvements.

Seeking was broken with recent Kodi versions due to a backwards-incompatible change in Kodi's protocol. The first commit fixes this.

There were several issues with interpreting Left/Right buttons as seeking vs. switching tracks/files. A timer measured the time elapsed from the most recent keydown event to the keyup event, and would interpret it as seeking if it was more than 150 ms.

  • 150 ms is too short a threshold: it's easy to accidentally do a longer press when one intends it to be short.
  • Switching to the next track is a more substantial action than seeking, so assigning it to a shorter press is confusing.
  • Most importantly, at least some phones send keydown events repeatedly (circa every 200 ms) while a key is held, so the timer did not actually measure how long the key was held. Whether a long press was interpreted as a long or short press was essentially random (technically depending on whether the remainder of the time the key was held with the key repetition frequency was above or below 150 ms).
  • Assigning track switching and seeking to the same key can't work well anyway because it's prone to mistakes where the user accidentally switches tracks (and thus loses one's position) when intending to seek.

The second commit assigns seeking to the Left/Right keys on the D-pad, going backward/forward in the playlist to the softkeys, and the menu that was previously assigned to SoftLeft to the Call button. Long pressing the D-pad Left/Right keys repeats seeking every 250 ms. Subsequent keydown events while holding the button are ignored. The third commit refines this by taking the amounts of time to seek by, and the repetition delay, from the Kodi settings if possible.

See the commit messages' description lines (click ... next to the commit message) for more details on the other commits. If you don't want to apply all commits, you can cherry-pick what you want, though some commits rely on changes made in some earlier commits.

Adapt to breaking change in the Kodi JSON-RPC protocol
xbmc/xbmc#15939
ArrowLeft/ArrowRight only seek, long press seeks repeatedly
SoftLeft/SoftRight go forward/backward in playlist
Call opens player options
Support calling multiple methods in a single request to simplify async
code and improve performance over separate requests.
JSON-RPC supports this by sending and receiving arrays.
As a further improvement, use the user's seeksteps and seekdelay
settings from Kodi: gradually increasing steps.
Though we use them differently: in Kodi, one has to press the arrow
keys repeatedly, and the delay determines when steps are reset,
while in Kaidi, now one has to long-press Left/Right, and the delay
determines the key repetition frequency.
Update the player time when seeking, to make it easier to seek
(since in some cases it doesn't show up on the Kodi screen when
playing music).
Update info such as track title during polling, along with time.
Since we're polling every 2 seconds anyway, requesting some more info
has little extra cost.
Events only work with the port 9090 interface, which is very insecure;
this way, Kaidi is more usable when only the web server interface is
available.
It improves seeking in particular.
Playing status is now only hidden when there is no active player at all.
Also use refreshProperties() at the beginning instead of duplicate code.
Use the visibilitychange event to start/stop the timer.
This should save a little battery.
Continue polling even when the player isn't running.
This doesn't make sense if Kodi events are available, but if events
don't work, it makes Kaidi recognize when another client starts playback
or switches tracks while playback isn't running.
In conjunction with stopping polling when the document is invisible, it
should have little cost.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant