Skip to content

Commit

Permalink
Wait for video element ready state to change to HAVE_METADATA before …
Browse files Browse the repository at this point in the history
…triggering STREAM_INITIALIZED (#3824)
  • Loading branch information
dsilhavy authored Dec 2, 2021
1 parent 00f6ecb commit 2a6be28
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 38 deletions.
8 changes: 5 additions & 3 deletions src/streaming/Stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -734,9 +734,11 @@ function Stream(config) {
errHandler.error(error);
} else if (!isInitialized) {
isInitialized = true;
eventBus.trigger(Events.STREAM_INITIALIZED, {
streamInfo: streamInfo
});
videoModel.waitForReadyState(Constants.VIDEO_ELEMENT_READY_STATES.HAVE_METADATA, () => {
eventBus.trigger(Events.STREAM_INITIALIZED, {
streamInfo: streamInfo
});
})
}

}
Expand Down
71 changes: 36 additions & 35 deletions src/streaming/models/VideoModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,42 +425,43 @@ function VideoModel() {
}

instance = {
initialize: initialize,
setCurrentTime: setCurrentTime,
play: play,
isPaused: isPaused,
pause: pause,
initialize,
setCurrentTime,
play,
isPaused,
pause,
isStalled,
isSeeking: isSeeking,
getTime: getTime,
getPlaybackRate: getPlaybackRate,
setPlaybackRate: setPlaybackRate,
getPlayedRanges: getPlayedRanges,
getEnded: getEnded,
setStallState: setStallState,
getElement: getElement,
setElement: setElement,
setSource: setSource,
getSource: getSource,
getTTMLRenderingDiv: getTTMLRenderingDiv,
setTTMLRenderingDiv: setTTMLRenderingDiv,
getPlaybackQuality: getPlaybackQuality,
addEventListener: addEventListener,
removeEventListener: removeEventListener,
getReadyState: getReadyState,
getBufferRange: getBufferRange,
getClientWidth: getClientWidth,
getClientHeight: getClientHeight,
getTextTracks: getTextTracks,
getTextTrack: getTextTrack,
addTextTrack: addTextTrack,
appendChild: appendChild,
removeChild: removeChild,
getVideoWidth: getVideoWidth,
getVideoHeight: getVideoHeight,
getVideoRelativeOffsetTop: getVideoRelativeOffsetTop,
getVideoRelativeOffsetLeft: getVideoRelativeOffsetLeft,
reset: reset
isSeeking,
getTime,
getPlaybackRate,
setPlaybackRate,
getPlayedRanges,
getEnded,
setStallState,
getElement,
setElement,
setSource,
getSource,
getTTMLRenderingDiv,
setTTMLRenderingDiv,
getPlaybackQuality,
addEventListener,
removeEventListener,
getReadyState,
getBufferRange,
getClientWidth,
getClientHeight,
getTextTracks,
getTextTrack,
addTextTrack,
appendChild,
removeChild,
getVideoWidth,
getVideoHeight,
getVideoRelativeOffsetTop,
getVideoRelativeOffsetLeft,
waitForReadyState,
reset
};

setup();
Expand Down

0 comments on commit 2a6be28

Please sign in to comment.