Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make media.currentTime more accurate during seeking #7638

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

domenic
Copy link
Member

@domenic domenic commented Feb 18, 2022

Previously, currentTime always returned the "official playback position", which is only periodically synced with the "current playback position". In particular, if JavaScript code performs a seek (e.g. using the seek() method), this would not sync them until a stable state is reached. (I.e., until that JavaScript code runs to completion.)

This shows up particularly in the case where currentTime is set to a value outside of the timeline, e.g. Number.MAX_VALUE. The previous spec would cause whatever is passed to the currentTime setter, to then be returned by the currentTime getter. But Chromium and Gecko instead clamped the result to the timeline. Chromium's implementation of this, in particular, is to return the current playback position during the seek process, which is what we have specified here.

See web-platform-tests/wpt#32832 for more discussion.

(See WHATWG Working Mode: Changes for more details.)


/media.html ( diff )

Previously, currentTime always returned the "official playback position", which is only periodically synced with the "current playback position". In particular, if JavaScript code performs a seek (e.g. using the seek() method), this would not sync them until a stable state is reached. (I.e., until that JavaScript code runs to completion.)

This shows up particularly in the case where currentTime is set to a value outside of the timeline, e.g. Number.MAX_VALUE. The previous spec would cause whatever is passed to the currentTime setter, to then be returned by the currentTime getter. But Chromium and Gecko instead clamped the result to the timeline. Chromium's implementation of this, in particular, is to return the current playback position during the seek process, which is what we have specified here.

See web-platform-tests/wpt#32832 for more discussion.
@jernoble
Copy link

jernoble commented Feb 18, 2022

If I understand the changes proposed by @domenic correctly, setting currentTime to some !currentTime would result in currentTime returning the prior currentTime, not the clamped value as requested in the WPT issue.

So, you'd end up with something like:

> video.currentTime
< 1
> video.duration
< 60
> video.currentTime = 120
< 1
> video.currentTime
< 1

And this ends up with weird behavior if you do something like:

> video1.currentTime = video2.currentTime = 120

Where video1 will get seeded to video2's initial currentTime, not 120, and not 120 clamped to video2's duration.

Am I misunderstanding the proposal to return current playback position if the seeking flag is true?

@jernoble
Copy link

Even if the above issue is fixed (for example, by modifying the "current time setter steps" to clamp "given value" to the media timeline), this still leads to weird behavior where, e.g.:

video1.currentTime = video2.currentTime = Number.MAX_VALUE

Will result in video1's currentTime being set to video2's duration, not Number.MAX_VALUE. This seems like it breaks the expectation of JavaScript that the return value of an assignment is the same as the assigned value, and makes things like chaining assignments particularly dangerous.

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

Successfully merging this pull request may close these issues.

2 participants