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 PR will...
Improve end-of-stream handling in Firefox and Safari with multi-track streams
Why is this Pull Request needed?
Playback can stall when seeking to the end of streams. This is often why our functional tests fail in Safari and Firefox. These changes help the case where these tests would timeout completely because both 'seeked' and 'ended' events never fire.
HLS.js now calls
mediaSource.endOfStream()
only once after both audio and video tracks have appended their final segment, and both SourceBuffers are markedended
prevents playback from stalling while seeking to the end. The 'ended' event still may not fire in cases where audio and video are not aligned near the end.Before, each call to
mediaSource.endOfStream()
triggered a "durationchange" on the video element. This was happening twice, once for each track, with some streams. Now, since the duration already set should match the end of the stream after both SourceBuffers are markedended
, we shouldn't see any additional "durationchange" events unless a level or track switch produces a new track end time.Steps to repro:
Expected behavior:
Seeks and plays last 3 seconds then ends
Actual behavior:
Stalls in the "seeking" state at (duration-3)
Checklist