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

TV playback controls: add fast seeking and enable track selection without pausing #870

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

voodoos
Copy link
Contributor

@voodoos voodoos commented Oct 27, 2024

Hi @jarnedemeulemeester thanks a lot for your work ! I am using the Android TV version of Findroid because the playback is much more robust than the official one. But I found the controls to be a bit finicky... here is a proposition to improve them a bit, adding fast seeking and track switching without pause. I hope this is of interest to you ! It is my first time using Compose so I would be happy to receive feedback and improve my code.

This PR proposes an addition to the current playback controls to allow seeking and changing tracks without pausing the playback.

The current controls are especially tedious to use for seeking:

  1. First press the Enter key to pause to show the controls. This also pauses the playback.
  2. Navigate to the seeker (right then bottom).
  3. Activate seeking by pressing Enter.
  4. Seek by pressing multiple times Right or Left.
  5. Validate by pressing Enter.
  6. Press Enter to resume the playback.

This PR adds two new behaviors:

  1. Fast-seeking by pressing Right or Left keys during playback while the controls are not shown.
  2. During, playback, pressing the Up shows the controls without pausing the playback which allows changing the audio or subtitle tracks without pausing.

However, I had to inhibit several current behaviors to achieve that:

  • When seeking, the player state briefly switches to paused while buffering. But this is not a pause to which the UI should react. In commit dc1aac3 I make UI pause-state independent from the player's own state so that we can have finer behaviors.
  • The Box containing the video surface has custom bindings for the D-pad keys: on Enter it pauses playback and shows the controls. These actions were still performed while the controls were shown (without a negative impact). In commit a8461c1 I restrict these actions to trigger only if the player box is in focus. This prevent fast-seek on Right and Left to trigger while navigating in the controls.
  • Opening a track selection dialog pauses the player's activity which used to pause the playback. In c30bc52 I disable that behavior to allow track switching without pausing.

Here is a screencast showing seeking and switching subtitles without pausing:

Screencast_20241027_125214.webm.mov

Some player action like seeking does not require pausing from the User point of view but will trigger a short pause of the player while buffering.
This allows switching audio/subtitles tracks while keeping the video playing.
This is not optimal behavior. Further improvements to the seekbar are needed.
@voodoos
Copy link
Contributor Author

voodoos commented Oct 27, 2024

I see that linting fails due to some style issues (and missing imports). Is there anyway for me to configure my Android Studio to enforce these styles ?

@jarnedemeulemeester
Copy link
Owner

I see that linting fails due to some style issues (and missing imports). Is there anyway for me to configure my Android Studio to enforce these styles ?

I don't know of a way to show the linting errors in Android Studio. However you can run ./gradlew ktlintFormat to check and lint your code

@jarnedemeulemeester
Copy link
Owner

I like the changes to open up the controls without pausing the playback.
But I am not sure if coupling isPlaying to the user interaction is a good idea. What if the playback get's pause by the mediasession from for example a phone or something?

@voodoos
Copy link
Contributor Author

voodoos commented Nov 5, 2024

But I am not sure if coupling isPlaying to the user interaction is a good idea. What if the playback get's pause by the mediasession from for example a phone or something?

I think you're right, it's not completely satisfying right now, and I noticed some strange behavior sometimes when sending some inputs right after starting the videos that might be linked to that. I will try to rework it in the following weeks. I do think we need to have some kind of fast seeking that doesn't have to show the controls however, not sure how that can be achieved...

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.

2 participants