1
0
mirror of https://github.com/videojs/video.js.git synced 2025-07-17 01:42:41 +02:00

fix: set liveWindow to 0 liveCurrentTime is Infinity (#7034)

Fixes an issue in native Safari and Android HLS playback where liveCurrentTime returns Infinity (as we don't have a seekableEnd or seekableEnd is actually Infinity). Which causes the new live ui to show up when we don't really have a live window.

Instead of returning Infinity when liveCurrentTime is Infinity, return 0. So that everything knows that we do not have a seekable window of live playback.
This commit is contained in:
Brandon Casey
2021-01-11 17:24:53 -05:00
committed by GitHub
parent f87297b20e
commit 330c82c88f
2 changed files with 6 additions and 5 deletions

View File

@ -103,7 +103,7 @@ class LiveTracker extends Component {
// we cannot be behind if // we cannot be behind if
// 1. until we have not seen a timeupdate yet // 1. until we have not seen a timeupdate yet
// 2. liveCurrentTime is Infinity, which happens on Android // 2. liveCurrentTime is Infinity, which happens on Android and Native Safari
if (!this.timeupdateSeen_ || liveCurrentTime === Infinity) { if (!this.timeupdateSeen_ || liveCurrentTime === Infinity) {
isBehind = false; isBehind = false;
} }
@ -275,8 +275,9 @@ class LiveTracker extends Component {
liveWindow() { liveWindow() {
const liveCurrentTime = this.liveCurrentTime(); const liveCurrentTime = this.liveCurrentTime();
// if liveCurrenTime is Infinity then we don't have a liveWindow at all
if (liveCurrentTime === Infinity) { if (liveCurrentTime === Infinity) {
return Infinity; return 0;
} }
return liveCurrentTime - this.seekableStart(); return liveCurrentTime - this.seekableStart();

View File

@ -290,7 +290,7 @@ QUnit.module('LiveTracker', () => {
QUnit.test('single seekable with Infinity, helpers should be correct', function(assert) { QUnit.test('single seekable with Infinity, helpers should be correct', function(assert) {
// single with Infinity // single with Infinity
this.player.seekable = () => createTimeRanges(0, Infinity); this.player.seekable = () => createTimeRanges(0, Infinity);
assert.strictEqual(this.liveTracker.liveWindow(), Infinity, 'liveWindow is Infinity'); assert.strictEqual(this.liveTracker.liveWindow(), 0, 'liveWindow is Infinity');
assert.strictEqual(this.liveTracker.seekableStart(), 0, 'seekableStart is 0s'); assert.strictEqual(this.liveTracker.seekableStart(), 0, 'seekableStart is 0s');
assert.strictEqual(this.liveTracker.seekableEnd(), Infinity, 'seekableEnd is Infinity'); assert.strictEqual(this.liveTracker.seekableEnd(), Infinity, 'seekableEnd is Infinity');
}); });
@ -298,7 +298,7 @@ QUnit.module('LiveTracker', () => {
QUnit.test('multiple seekables with Infinity, helpers should be correct', function(assert) { QUnit.test('multiple seekables with Infinity, helpers should be correct', function(assert) {
// multiple with Infinity // multiple with Infinity
this.player.seekable = () => createTimeRanges([[0, Infinity], [1, Infinity]]); this.player.seekable = () => createTimeRanges([[0, Infinity], [1, Infinity]]);
assert.strictEqual(this.liveTracker.liveWindow(), Infinity, 'liveWindow is Infinity'); assert.strictEqual(this.liveTracker.liveWindow(), 0, 'liveWindow is Infinity');
assert.strictEqual(this.liveTracker.seekableStart(), 0, 'seekableStart is 0s'); assert.strictEqual(this.liveTracker.seekableStart(), 0, 'seekableStart is 0s');
assert.strictEqual(this.liveTracker.seekableEnd(), Infinity, 'seekableEnd is Infinity'); assert.strictEqual(this.liveTracker.seekableEnd(), Infinity, 'seekableEnd is Infinity');
}); });
@ -307,7 +307,7 @@ QUnit.module('LiveTracker', () => {
// defaults // defaults
this.player.seekable = () => createTimeRanges(); this.player.seekable = () => createTimeRanges();
assert.strictEqual(this.liveTracker.liveWindow(), Infinity, 'liveWindow is Infinity'); assert.strictEqual(this.liveTracker.liveWindow(), 0, 'liveWindow is Infinity');
assert.strictEqual(this.liveTracker.seekableStart(), 0, 'seekableStart is 0s'); assert.strictEqual(this.liveTracker.seekableStart(), 0, 'seekableStart is 0s');
assert.strictEqual(this.liveTracker.seekableEnd(), Infinity, 'seekableEnd is Infinity'); assert.strictEqual(this.liveTracker.seekableEnd(), Infinity, 'seekableEnd is Infinity');
}); });