6ad52bb2 by jrivera

Make expired time tracking contingent on setupFirstPlay succeeding

Don't increment seekable until the live stream has started to play. This more closely matches Safari's behavior WRT live stream and seekable.
1 parent c010d49b
...@@ -94,6 +94,10 @@ ...@@ -94,6 +94,10 @@
94 94
95 PlaylistLoader.prototype.init.call(this); 95 PlaylistLoader.prototype.init.call(this);
96 96
97 // a flag that disables "expired time"-tracking this setting has
98 // no effect when not playing a live stream
99 this.trackExpiredTime_ = false;
100
97 if (!srcUrl) { 101 if (!srcUrl) {
98 throw new Error('A non-empty playlist URL is required'); 102 throw new Error('A non-empty playlist URL is required');
99 } 103 }
...@@ -267,6 +271,12 @@ ...@@ -267,6 +271,12 @@
267 loader.bandwidth = xhr.bandwidth; 271 loader.bandwidth = xhr.bandwidth;
268 }; 272 };
269 273
274 // In a live list, don't keep track of the expired time until
275 // HLS tells us that "first play" has commenced
276 loader.on('firstplay', function() {
277 this.trackExpiredTime_ = true;
278 });
279
270 // live playlist staleness timeout 280 // live playlist staleness timeout
271 loader.on('mediaupdatetimeout', function() { 281 loader.on('mediaupdatetimeout', function() {
272 if (loader.state !== 'HAVE_METADATA') { 282 if (loader.state !== 'HAVE_METADATA') {
...@@ -360,6 +370,14 @@ ...@@ -360,6 +370,14 @@
360 return; 370 return;
361 } 371 }
362 372
373 // don't track expired time until this flag is truthy
374 if (!this.trackExpiredTime_) {
375 return;
376 }
377
378 // if the update was the result of a rendition switch do not
379 // attempt to calculate expired_ since media-sequences need not
380 // correlate between renditions/variants
363 if (update.uri !== outdated.uri) { 381 if (update.uri !== outdated.uri) {
364 return; 382 return;
365 } 383 }
......
...@@ -430,6 +430,9 @@ videojs.HlsHandler.prototype.setupFirstPlay = function() { ...@@ -430,6 +430,9 @@ videojs.HlsHandler.prototype.setupFirstPlay = function() {
430 // at least HAVE_FUTURE_DATA 430 // at least HAVE_FUTURE_DATA
431 this.tech_.readyState() >= 1) { 431 this.tech_.readyState() >= 1) {
432 432
433 // trigger the playlist loader to start "expired time"-tracking
434 this.playlists.trigger('firstplay');
435
433 // seek to the latest media position for live videos 436 // seek to the latest media position for live videos
434 seekable = this.seekable(); 437 seekable = this.seekable();
435 if (seekable.length) { 438 if (seekable.length) {
......