From 39b55e6849d462c7f032a14b8b04809bf49fe970 Mon Sep 17 00:00:00 2001 From: Bertrand Berthelot Date: Fri, 4 Feb 2022 11:29:59 +0100 Subject: [PATCH 1/3] VideoModel: fix returned current time and seeking state according to current seeking value --- src/streaming/models/VideoModel.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/streaming/models/VideoModel.js b/src/streaming/models/VideoModel.js index ac642dbfb8..86dd93d033 100644 --- a/src/streaming/models/VideoModel.js +++ b/src/streaming/models/VideoModel.js @@ -48,6 +48,7 @@ function VideoModel() { let instance, logger, element, + seekingTime, TTMLRenderingDiv, previousPlaybackRate; @@ -59,6 +60,7 @@ function VideoModel() { function setup() { logger = Debug(context).getInstance().getLogger(instance); + seekingTime = NaN; } function initialize() { @@ -88,6 +90,7 @@ function VideoModel() { //TODO Move the DVR window calculations from MediaPlayer to Here. function setCurrentTime(currentTime, stickToBuffered) { + seekingTime = currentTime; waitForReadyState(Constants.VIDEO_ELEMENT_READY_STATES.HAVE_METADATA, () => { if (element) { //_currentTime = currentTime; @@ -106,6 +109,7 @@ function VideoModel() { try { currentTime = stickToBuffered ? stickTimeToBuffered(currentTime) : currentTime; element.currentTime = currentTime; + seekingTime = NaN; } catch (e) { if (element.readyState === 0 && e.code === e.INVALID_STATE_ERR) { setTimeout(function () { @@ -287,11 +291,11 @@ function VideoModel() { } function isSeeking() { - return element ? element.seeking : null; + return element ? (element.seeking || !isNaN(seekingTime)) : null; } function getTime() { - return element ? element.currentTime : null; + return element ? (!isNaN(seekingTime) ? seekingTime : element.currentTime) : null; } function getPlaybackRate() { From 6d9e499a166f9ad9a43ea21ee6351ee451397940 Mon Sep 17 00:00:00 2001 From: Bertrand Berthelot Date: Fri, 4 Feb 2022 13:51:27 +0100 Subject: [PATCH 2/3] VideoModel: fix returned current time and seeking state according to current seeking value --- src/streaming/models/VideoModel.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/streaming/models/VideoModel.js b/src/streaming/models/VideoModel.js index 86dd93d033..947405f6a2 100644 --- a/src/streaming/models/VideoModel.js +++ b/src/streaming/models/VideoModel.js @@ -48,7 +48,7 @@ function VideoModel() { let instance, logger, element, - seekingTime, + _currentTime, TTMLRenderingDiv, previousPlaybackRate; @@ -60,7 +60,7 @@ function VideoModel() { function setup() { logger = Debug(context).getInstance().getLogger(instance); - seekingTime = NaN; + _currentTime = NaN; } function initialize() { @@ -90,14 +90,12 @@ function VideoModel() { //TODO Move the DVR window calculations from MediaPlayer to Here. function setCurrentTime(currentTime, stickToBuffered) { - seekingTime = currentTime; + _currentTime = currentTime; waitForReadyState(Constants.VIDEO_ELEMENT_READY_STATES.HAVE_METADATA, () => { if (element) { - //_currentTime = currentTime; - // We don't set the same currentTime because it can cause firing unexpected Pause event in IE11 // providing playbackRate property equals to zero. - if (element.currentTime === currentTime) { + if (element.currentTime === _currentTime) { return; } @@ -107,13 +105,14 @@ function VideoModel() { // set currentTime even if readyState = 0. // setTimeout is used to workaround InvalidStateError in IE11 try { - currentTime = stickToBuffered ? stickTimeToBuffered(currentTime) : currentTime; - element.currentTime = currentTime; - seekingTime = NaN; + _currentTime = stickToBuffered ? stickTimeToBuffered(_currentTime) : _currentTime; + element.currentTime = _currentTime; + _currentTime = NaN; } catch (e) { if (element.readyState === 0 && e.code === e.INVALID_STATE_ERR) { setTimeout(function () { - element.currentTime = currentTime; + element.currentTime = _currentTime; + _currentTime = NaN; }, 400); } } @@ -291,11 +290,11 @@ function VideoModel() { } function isSeeking() { - return element ? (element.seeking || !isNaN(seekingTime)) : null; + return element ? (element.seeking || !isNaN(_currentTime)) : null; } function getTime() { - return element ? (!isNaN(seekingTime) ? seekingTime : element.currentTime) : null; + return element ? (!isNaN(_currentTime) ? _currentTime : element.currentTime) : null; } function getPlaybackRate() { From b3abbf4820631a86b724cb97debec4158f7f9e0b Mon Sep 17 00:00:00 2001 From: Bertrand Berthelot Date: Tue, 8 Feb 2022 09:31:33 +0100 Subject: [PATCH 3/3] VideoModel: fix returned current time and seeking state according to current seeking value --- src/streaming/models/VideoModel.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/streaming/models/VideoModel.js b/src/streaming/models/VideoModel.js index 947405f6a2..78fb4ccf40 100644 --- a/src/streaming/models/VideoModel.js +++ b/src/streaming/models/VideoModel.js @@ -96,6 +96,7 @@ function VideoModel() { // We don't set the same currentTime because it can cause firing unexpected Pause event in IE11 // providing playbackRate property equals to zero. if (element.currentTime === _currentTime) { + _currentTime = NaN; return; }