From 7d9f01899bccfbd9c8945d0aa411a1c9098fddab Mon Sep 17 00:00:00 2001 From: Oren Me Date: Thu, 30 Nov 2023 21:04:35 +0200 Subject: [PATCH 1/2] fix: remove source tag before config is reset --- .../media-source/adapters/native-adapter.js | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/engines/html5/media-source/adapters/native-adapter.js b/src/engines/html5/media-source/adapters/native-adapter.js index 2e16f446f..f5418fdb6 100644 --- a/src/engines/html5/media-source/adapters/native-adapter.js +++ b/src/engines/html5/media-source/adapters/native-adapter.js @@ -629,20 +629,14 @@ export default class NativeAdapter extends BaseMediaSourceAdapter { destroy(): Promise<*> { NativeAdapter._logger.debug('destroy'); return new Promise((resolve, reject) => { + //must be called before super config cause it requires config which is reset in super destroy + this._removeSourceTag(); super.destroy().then( () => { this._drmHandler && this._drmHandler.destroy(); this._waitingEventTriggered = false; this._progressiveSources = []; this._loadPromise = null; - if (this._config['useSourceTag'] && this._videoElement) { - const source = this._videoElement.firstChild; - if (source) { - Utils.Dom.setAttribute(source, 'src', ''); - Utils.Dom.removeAttribute(source, 'src'); - Utils.Dom.removeChild(this._videoElement, source); - } - } this._nativeTextTracksMap = {}; this._loadPromiseReject = null; this._liveEdge = 0; @@ -663,6 +657,23 @@ export default class NativeAdapter extends BaseMediaSourceAdapter { }); } + /** + * remove source tag + * @function _removeSourceTag + * @returns {void} + * @private + */ + _removeSourceTag(): void { + if (this._config.useSourceTag && this._videoElement) { + const source = this._videoElement.firstChild; + if (source) { + Utils.Dom.setAttribute(source, 'src', ''); + Utils.Dom.removeAttribute(source, 'src'); + Utils.Dom.removeChild(this._videoElement, source); + } + } + } + /** * Get the parsed tracks * @function _getParsedTracks From d6507180cb98ffbb86bc53dad6d57ada223a2baf Mon Sep 17 00:00:00 2001 From: Oren Me Date: Thu, 30 Nov 2023 21:06:00 +0200 Subject: [PATCH 2/2] update name of method --- src/engines/html5/media-source/adapters/native-adapter.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engines/html5/media-source/adapters/native-adapter.js b/src/engines/html5/media-source/adapters/native-adapter.js index f5418fdb6..3c149bc68 100644 --- a/src/engines/html5/media-source/adapters/native-adapter.js +++ b/src/engines/html5/media-source/adapters/native-adapter.js @@ -630,7 +630,7 @@ export default class NativeAdapter extends BaseMediaSourceAdapter { NativeAdapter._logger.debug('destroy'); return new Promise((resolve, reject) => { //must be called before super config cause it requires config which is reset in super destroy - this._removeSourceTag(); + this._maybeRemoveSourceTag(); super.destroy().then( () => { this._drmHandler && this._drmHandler.destroy(); @@ -659,11 +659,11 @@ export default class NativeAdapter extends BaseMediaSourceAdapter { /** * remove source tag - * @function _removeSourceTag + * @function _maybeRemoveSourceTag * @returns {void} * @private */ - _removeSourceTag(): void { + _maybeRemoveSourceTag(): void { if (this._config.useSourceTag && this._videoElement) { const source = this._videoElement.firstChild; if (source) {