Fix a few inconsistencies between the media element spec and implementations #11792
+33
−18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes a few inconsistencies between the spec and browsers' implementations of a few behaviors:
Media elements' seek steps do not set the official playback position before parallel steps begin #11773: A script is not immediately guaranteed to receive a playback position on the media timeline after setting
currentTime
:The fix for this issue is to specify that the
currentTime
setter returns the value passed to it, and that the seek steps should synchronously set the official playback position to the chosen new playback position after clamping it to the earliest possible position, the duration, and the seekable ranges. This also ensures thatcurrentTime
reflects the new playback time after callingfastSeek()
, which matches Firefox and Safari behavior.Media elements can loop if they reach the end of media playback while paused #11774: Seeking to the end of a video while paused loops to the start:
In order to fix this, when reaching the end of playback while the loop attribute is set, the seek to the earliest position is only run when not paused. In order to allow playback to restart when that condition does not pass, the internal play steps must then seek to the start if looping was skipped due to being paused the last time they were run.
Media element is not considered to have ended playback if loop is enabled after reaching the end #11775: Finally, if the
loop
attribute is set after playback has ended:This is solved by specifying that playback has ended when the
loop
attribute was specified the last time that the end of playback was reached, meaning that modifying it before playback ends again does not affect the value of theended
attribute. This also allows playback to restart from the beginning even after specifyingloop
while playback is ended.(See WHATWG Working Mode: Changes for more details.)