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

bugfix/reset-race-conditions #4246

Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions src/streaming/controllers/BufferController.js
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,10 @@ function BufferController(config) {
function _onRemoved(e) {
logger.debug('onRemoved buffer from:', e.from, 'to', e.to);

if (!sourceBufferSink) {
return;
}

const ranges = sourceBufferSink.getAllBufferRanges();
_showBufferRanges(ranges);

Expand Down
10 changes: 8 additions & 2 deletions src/streaming/models/VideoModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ function VideoModel() {
_currentTime,
TTMLRenderingDiv,
vttRenderingDiv,
previousPlaybackRate;
previousPlaybackRate,
timeout;

const VIDEO_MODEL_WRONG_ELEMENT_TYPE = 'element is not video or audio DOM type!';

Expand All @@ -69,6 +70,7 @@ function VideoModel() {
}

function reset() {
clearTimeout(timeout);
eventBus.off(Events.PLAYBACK_PLAYING, onPlaying, this);
}

Expand All @@ -94,6 +96,10 @@ function VideoModel() {
if (element) {
_currentTime = currentTime;
waitForReadyState(Constants.VIDEO_ELEMENT_READY_STATES.HAVE_METADATA, () => {
if (!element) {
return;
}

// 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) {
Expand All @@ -112,7 +118,7 @@ function VideoModel() {
_currentTime = NaN;
} catch (e) {
if (element.readyState === 0 && e.code === e.INVALID_STATE_ERR) {
setTimeout(function () {
timeout = setTimeout(function () {
element.currentTime = _currentTime;
_currentTime = NaN;
}, 400);
Expand Down