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

Limit speed at live edge #8134

Closed
wants to merge 10 commits into from

Conversation

KosOrKosm
Copy link

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

  • Upon reaching the live edge of a livestream, if playback speed is greater than 100%, set it to 100%.
  • The maximum playback speed that can be set in the PlaybackParameterDialog is reduced to 100% when on the live edge.
  • The PlaybackParameterDialog skip silence button is also hidden on the live edge.

Note it is still possible to use playbacks speeds <= 100% at all times on livestreams, and playback speeds > 100% when not on the live edge.

Changes tested on emulator (Pixel 3a w/ API 28).

Before/After Screenshots

Before: After:
PR2 - NonlivePlaybackParamDialog PR2 - LivePlaybackParamDialog

Fixes the following issue(s)

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.

Due diligence

@AudricV
Copy link
Member

AudricV commented Apr 3, 2022

Thank you for the pull request!

I know I am bit against these changes, but what do you think of setting only the playback speed to 1x by default only on livestreams? This will allow users to watch streams from the start of the live window up to the maximum speed supported in the app (see what I wrote in #7667 (comment) for more details).

So if users increased playback speed and they have issues when using it at the live edge, then they can understand the issue is from them, not from us.

@KosOrKosm
Copy link
Author

@TiA4f8R Thank you for the feedback!

I was considering setting the default playback speed to 1x for livestreams, but I thought this solution might be less intrusive. This approach allows the user to speed up in the live window, just not in the live edge. In my testing, Youtube livestreams had an ~30 second live window, and only ~5 seconds of that window was the live edge. So only those last ~5 seconds cannot be sped up, and the rest of the window can still be freely controlled. I think this allows the user the most freedom without causing an unpleasant experience due to buffering at the live edge.

In terms of notifying the user, I wasn't sure if any notification was necessary. It could be surprising for the user that the speed resets at the live edge, but I also think it might be clear why it occurs. Perhaps a popup message could appear when the speed is reset to explain why it is happening?

@AudricV
Copy link
Member

AudricV commented Apr 3, 2022

In my testing, Youtube livestreams had an ~30 second live window, and only ~5 seconds of that window was the live edge.

This will be changed with my PR, depending of the streams, up to one hour (for livestreams with DVR of course).

This approach allows the user to speed up in the live window, just not in the live edge

Why not using what YouTube does? When coming to the live edge or being behind the live window, YouTube player(s) reset(s) the playback speed to 1x and seek(s) to the default position. This would solve all the issues without preventing users to select the playback speed. In this case, of course, 1x should be not saved as the default playback speed for videos.

@KosOrKosm
Copy link
Author

KosOrKosm commented Apr 3, 2022

Why not using what YouTube does?

I had also considered this method. I preferred locking to the default seek position (the current implementation), rather than allowing the user to briefly accelerate past it only to send them back moments later once buffering occurs.

I can use the same strategy as Youtube simply by moving the new logic from onUpdateProgress to onBuffering + adding a seek to default. Would this be the best / preferred approach?

@KosOrKosm
Copy link
Author

Hello @litetex, can you review my pull request?

@litetex
Copy link
Member

litetex commented Apr 9, 2022

Blocked by #7989

@KosOrKosm
Copy link
Author

Ahh, I see. @litetex Could I close this PR and open a new one without the speed dialogue changes? I can just use the same strategy as Youtube and reset playback speed when buffering at the live edge. That will solve the underlying issue without interfering with any incoming changes to the dialogue.

Sorry, I am relatively new to Github, so I'm not sure if this would be appropriate.

@Stypox
Copy link
Member

Stypox commented Apr 30, 2022

@KosOrKosm no, you PR is perfectly fine, don't worry. What litetex was saying is probably that he wants to merge #7989 (which I will do now) before this PR since they both edit the same file and that causes merge conflicts. By merging #7989 I will create some merge conflicts for you, though, let me know if you need help with solving them ;-)

@Stypox
Copy link
Member

Stypox commented Apr 30, 2022

@KosOrKosm you might have to rewrite from scratch your changes to PlaybackParameterDialog since #7989 basically rewrote it from scratch, too.

@KosOrKosm KosOrKosm changed the base branch from dev to master April 30, 2022 17:12
@KosOrKosm KosOrKosm changed the base branch from master to dev April 30, 2022 17:12
@KosOrKosm
Copy link
Author

I reimplemented my tempo limit logic for PlaybackParameterDialog on the #7989 changes. I also merged with the latest version of dev.

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks almost good. Thank you!

@KosOrKosm
Copy link
Author

I pushed the requested changes.

@AudricV AudricV added feature request Issue is related to a feature in the app player Issues related to any player (main, popup and background) labels May 3, 2022
@sonarcloud
Copy link

sonarcloud bot commented May 3, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@litetex litetex self-requested a review May 3, 2022 19:37
Copy link
Member

@litetex litetex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just scrolled down a bit, noticed problem, block catastrophe.

I will review/test this in more detail once I have time and higher priority PRs are done.

@@ -1717,6 +1733,10 @@ private void onUpdateProgress(final int currentProgress,
}
binding.playbackLiveSync.setClickable(!isLiveEdge());

if (isLiveEdge() && getPlaybackSpeed() > 1.0f) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you notice that this is run constantly in a loop?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did realize this is a function that is executing very frequently, but I wanted the playback speed to reset the moment the live edge was reached and wasn't sure if there was a better place to put the logic.

This logic could be moved to onBuffering(), which would match Youtube's livestreaming behavior and avoid calling the check in a loop. The downside is that the speed reset won't occur immediately after hitting the live edge.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more resource-heavy part here is probably calculating isLiveEdge, seeing it is not a trivial function.

Comment on lines 1734 to +1736
binding.playbackLiveSync.setClickable(!isLiveEdge());

if (isLiveEdge() && getPlaybackSpeed() > 1.0f) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then probably we can just do this:

Suggested change
binding.playbackLiveSync.setClickable(!isLiveEdge());
if (isLiveEdge() && getPlaybackSpeed() > 1.0f) {
// if live edge of a livestream -> no need for sync button; playback speed must be <= 1.0
final boolean liveEdge = isLiveEdge();
binding.playbackLiveSync.setClickable(!liveEdge);
if (liveEdge && getPlaybackSpeed() > 1.0f) {

@Stypox
Copy link
Member

Stypox commented Mar 30, 2024

I'm closing this due to inactivity and due to the fact that we're soon starting the rewrite and we don't want to touch the player and possibly introduce regressions. Thank you anyway for your effort!

@Stypox Stypox closed this Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issue is related to a feature in the app player Issues related to any player (main, popup and background)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Livestreams should not have playback parameters (speed adjustment or skip silence)
4 participants