mirror of
https://github.com/videojs/video.js.git
synced 2025-01-04 06:48:49 +02:00
revert: Revert "fix(iOS): pause player on suspend or stalled if extra buffer is available (#6199)" (#6373)
This reverts commit c791cd8c4e
.
Fixes #6330
This commit is contained in:
parent
cd4076a566
commit
17d8046836
@ -111,10 +111,6 @@ class Html5 extends Tech {
|
||||
// into a `fullscreenchange` event
|
||||
this.proxyWebkitFullscreen_();
|
||||
|
||||
if (browser.IS_IOS) {
|
||||
this.handleIOSHeadphonesDisconnection_();
|
||||
}
|
||||
|
||||
this.triggerReady();
|
||||
}
|
||||
|
||||
@ -208,50 +204,6 @@ class Html5 extends Tech {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle IOS Headphone disconnection during playback
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
handleIOSHeadphonesDisconnection_() {
|
||||
// Fudge factor to account for TimeRanges rounding
|
||||
const TIME_FUDGE_FACTOR = 1 / 30;
|
||||
|
||||
// Comparisons between time values such as current time and the end of the buffered range
|
||||
// can be misleading because of precision differences or when the current media has poorly
|
||||
// aligned audio and video, which can cause values to be slightly off from what you would
|
||||
// expect. This value is what we consider to be safe to use in such comparisons to account
|
||||
// for these scenarios.
|
||||
const SAFE_TIME_DELTA = TIME_FUDGE_FACTOR * 3;
|
||||
|
||||
// If iOS check if we have a real stalled or supend event or
|
||||
// we got stalled/suspend due headphones where disconnected during playback
|
||||
this.on(['stalled', 'suspend'], (e) => {
|
||||
const buffered = this.buffered();
|
||||
|
||||
if (!buffered.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
let extraBuffer = false;
|
||||
const currentTime = this.currentTime();
|
||||
|
||||
// Establish if we have an extra buffer in the current time range playing.
|
||||
for (let i = 0; i < buffered.length; i++) {
|
||||
if (buffered.start(i) <= currentTime &&
|
||||
currentTime < buffered.end(i) + SAFE_TIME_DELTA) {
|
||||
extraBuffer = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if tech is not paused, browser has internet connection & player has extraBuffer inside the timeRange
|
||||
if (extraBuffer && !this.paused() && window.navigator.onLine) {
|
||||
this.pause();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to force override of tracks for the given type
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user