From 166166169dd28d528b5ffd22508ac5c08f8c42cb Mon Sep 17 00:00:00 2001 From: "yair.ansbacher" Date: Sun, 25 Jul 2021 17:08:46 +0300 Subject: [PATCH] fix(FEC-11429): something went wrong when start playing live dash on IE11 - regression --- src/dash-adapter.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/dash-adapter.js b/src/dash-adapter.js index 441b4c06..a57570d6 100644 --- a/src/dash-adapter.js +++ b/src/dash-adapter.js @@ -733,7 +733,7 @@ export default class DashAdapter extends BaseMediaSourceAdapter { url: response.uri }); if (this.isLive()) { - this._videoElement.dispatchEvent(new window.Event(EventType.DURATION_CHANGE)); + this._dispatchNativeEvent(EventType.DURATION_CHANGE); } break; case shaka.net.NetworkingEngine.RequestType.MANIFEST: @@ -1228,18 +1228,29 @@ export default class DashAdapter extends BaseMediaSourceAdapter { if (event.buffering) { if (!this._waitingSent) { // The player enters the buffering state and 'waiting' event hasn't been sent by the HTMLVideoElement. - this._videoElement.dispatchEvent(new window.Event(EventType.WAITING)); + this._dispatchNativeEvent(EventType.WAITING); this._buffering = true; } } else { this._buffering = false; if (!this._videoElement.paused && !this._playingSent) { //the player leaves the buffering state. and 'playing' event hasn't been sent by the HTMLVideoElement. - this._videoElement.dispatchEvent(new window.Event(EventType.PLAYING)); + this._dispatchNativeEvent(EventType.PLAYING); } } } + _dispatchNativeEvent(type: string): void { + let event; + if (typeof window.Event === 'function') { + event = new Event(type); + } else { + event = document.createEvent('Event'); + event.initEvent(type, true, true); + } + this._videoElement.dispatchEvent(event); + } + /** * An handler to shaka drm session update event * @function _onDrmSessionUpdate @@ -1275,7 +1286,7 @@ export default class DashAdapter extends BaseMediaSourceAdapter { this._waitingSent = false; if (this._buffering) { // The player is in buffering state. - this._videoElement.dispatchEvent(new window.Event(EventType.WAITING)); + this._dispatchNativeEvent(EventType.WAITING); } }