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

Allow FireFox to play at readystate 2, but protect other browsers #363

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/js/videoFormats/es.upv.paella.hlsVideoFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,15 @@ export class HlsVideo extends Mp4Video {
else {
await (new Promise((resolve,reject) => {
const checkReady = () => {
// readyState === 2: HAVE_CURRENT_DATA. Data is available for the current playback
// position, but not enought to actually play more than one frame. In firefox, the
// video returns readyState === 2 when the video reaches the end, so the correct
// comparision here is >= instead of >
if (this.video.readyState >= 2) {
// Make a special case to allow Firefox to play at readyState 2.
// Browsers like Safari drop from readyState 3 to readyState 2 when the video is
// buffering and cannot be played. Chrome moves quickly between ready state
// 2 to 3 when it is able to play and is not impacted by this issue.
if (/Firefox/.test(navigator.userAgent) && this.video.readyState == 2) {
this._ready = true;
resolve();
}
else if (this.video.readyState > 2) {
this._ready = true;
resolve();
}
Expand Down
Loading