Skip to content

Commit

Permalink
fix: remove source tag before config is reset (#740)
Browse files Browse the repository at this point in the history
* fix: remove source tag before config is reset

* update name of method
  • Loading branch information
OrenMe authored Dec 1, 2023
1 parent 38cbbfb commit e413c40
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/engines/html5/media-source/adapters/native-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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._maybeRemoveSourceTag();
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;
Expand All @@ -663,6 +657,23 @@ export default class NativeAdapter extends BaseMediaSourceAdapter {
});
}

/**
* remove source tag
* @function _maybeRemoveSourceTag
* @returns {void}
* @private
*/
_maybeRemoveSourceTag(): 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
Expand Down

0 comments on commit e413c40

Please sign in to comment.