From 50cb134cb0e0331db63013f4b68b614a77bd87c4 Mon Sep 17 00:00:00 2001 From: "yuval.keidar" Date: Thu, 26 Nov 2020 16:17:28 +0200 Subject: [PATCH] fix(FEC-10662): incorrect flow in destroy process return promise which will be resolved or rejected on the end of reset. --- .../media-source/adapters/native-adapter.js | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/engines/html5/media-source/adapters/native-adapter.js b/src/engines/html5/media-source/adapters/native-adapter.js index 4ae40154b..a0a60e166 100644 --- a/src/engines/html5/media-source/adapters/native-adapter.js +++ b/src/engines/html5/media-source/adapters/native-adapter.js @@ -521,22 +521,28 @@ export default class NativeAdapter extends BaseMediaSourceAdapter { */ destroy(): Promise<*> { NativeAdapter._logger.debug('destroy'); - return super.destroy().then(() => { - this._drmHandler && this._drmHandler.destroy(); - this._waitingEventTriggered = false; - this._progressiveSources = []; - this._loadPromise = null; - this._loadPromiseReject = null; - this._liveEdge = 0; - this._lastTimeUpdate = 0; - this._lastTimeDetach = NaN; - this._startTimeAttach = NaN; - this._videoDimensions = null; - this._clearHeartbeatTimeout(); - if (this._liveDurationChangeInterval) { - clearInterval(this._liveDurationChangeInterval); - this._liveDurationChangeInterval = null; - } + return new Promise((resolve, reject) => { + super.destroy().then( + () => { + this._drmHandler && this._drmHandler.destroy(); + this._waitingEventTriggered = false; + this._progressiveSources = []; + this._loadPromise = null; + this._loadPromiseReject = null; + this._liveEdge = 0; + this._lastTimeUpdate = 0; + this._lastTimeDetach = NaN; + this._startTimeAttach = NaN; + this._videoDimensions = null; + this._clearHeartbeatTimeout(); + if (this._liveDurationChangeInterval) { + clearInterval(this._liveDurationChangeInterval); + this._liveDurationChangeInterval = null; + } + resolve(); + }, + () => reject + ); }); }