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

Update time bar more frequently for short videos #5040

Closed
perracodex opened this issue Nov 1, 2018 · 7 comments
Closed

Update time bar more frequently for short videos #5040

perracodex opened this issue Nov 1, 2018 · 7 comments
Assignees

Comments

@perracodex
Copy link

When playing a video the DefaultTimerBar updates the current seek position at 1 second intervals.
Is there any setting to set it at a smaller time precision, so the seekbar updates more smoothly for short videos?

@perracodex perracodex changed the title DEfaultTimeBar seekbar precision in playbak DefaultTimeBar seekbar precision in playbak Nov 1, 2018
@ojw28 ojw28 self-assigned this Nov 1, 2018
@ojw28 ojw28 changed the title DefaultTimeBar seekbar precision in playbak Update time bar more frequently for short videos Nov 1, 2018
@ojw28
Copy link
Contributor

ojw28 commented Nov 1, 2018

Do you just mean the frequency with which the current position is updated during playback (i.e. nothing to do with the user seeking to a different position)?

If so then the frequency is controlled in PlayerControlView.updateProgress rather than DefaultTimeBar. It's a bit more complicated than once every second. For example it'll update more frequently if the playback speed is faster than 1x. There is currently no easy way to change the update rate.

Perhaps we should further enhance the calculation take into account the media duration, and have it automatically update more frequently for short duration videos. That's probably better than requiring the application developer to set it themselves. Would that make sense?

@perracodex
Copy link
Author

Yes this is exactly what I meant.
For long videos it looks fine, but for shorter videos of just a few seconds would be better to see a smoother update instead of a second to second big jump.

@ojw28
Copy link
Contributor

ojw28 commented Nov 1, 2018

Thanks for confirming! We should probably do something like calculate what duration of elapsed time corresponds to 1dp of the screen, and incorporate that into the calculation. Doing this would also update the time bar more frequently on physically larger devices than on small ones, which also seems like a good idea.

I've already marked this as an enhancement, so we can use it for tracking.

@viethoa
Copy link

viethoa commented Jan 8, 2019

@ojw28 might I know the issue is fixed? And that pretty good if you can share your plan on it. Currently, I am playing a 30seconds video and this looks not really good now.

@szaboa
Copy link
Contributor

szaboa commented Feb 6, 2019

@ojw28
I had a quick look on this and I have an idea.. maybe it's the same as yours (?), I am not sure.

So we could specify the update length (thickness) in dp, let's say - update the time bar's progress always with 20dp, regardless of the duration.

For example:
timeBarWidth= 400 dp (this will vary on devices / tablets).
duration= 20 sec
updateDp= 20 dp

With these, we could calculate how many times we need to update the time bar with updateDp dps to fill it up, numberOfUpdates= timeBarWidth/ updateDp= 20.

To get how frequently we need to update, we just need to calculate duration/ numberOfUpdate which is 1 sec in this case.

If the duration is 10 sec, then with this logic the time bar would need to be updated in every 0.5 secs.

It seems to me that in this way we could keep smooth visual updates on the time bar regardless of the duration. However the above calculated update times can't be used for other operations, like updating the durationView, positionView because if the duration is for example 1h (3600s), then these text views won't be updated only after every 180 sec. So it seems the existing calculation of delayMs should be kept for things like this. Also I don't know how things should work for live streams where we don't have a duration.

Ok, so this was just an idea. I am curious if this concept could be used as a starting point or not.

@tonihei
Copy link
Collaborator

tonihei commented Feb 7, 2019

That sounds like a good approach. To prevent this issue with slow updates, you can probably just impose a maximum and a minimum update frequency (let's say 50ms < f < 500ms). Are you planning to submit a pull request for that? That would be great as we are not planning to do that soon.

@szaboa
Copy link
Contributor

szaboa commented Feb 7, 2019

Yes, I plan to work on this and submit a pull request once I am done.

@ojw28 ojw28 closed this as completed Apr 5, 2019
@google google locked and limited conversation to collaborators Aug 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants