From 9338b36b8ed89257221bce5bb94f0bf8a2476196 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Thu, 23 Sep 2021 21:12:16 +0300 Subject: [PATCH 1/3] Clear JavascriptSubtitlesOctopus when an error occurs --- src/plugins/htmlVideoPlayer/plugin.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/htmlVideoPlayer/plugin.js b/src/plugins/htmlVideoPlayer/plugin.js index 611240be3e..cf477bfd9d 100644 --- a/src/plugins/htmlVideoPlayer/plugin.js +++ b/src/plugins/htmlVideoPlayer/plugin.js @@ -1062,6 +1062,9 @@ function tryRemoveElement(elem) { workerUrl: `${appRouter.baseUrl()}/libraries/subtitles-octopus-worker.js`, legacyWorkerUrl: `${appRouter.baseUrl()}/libraries/subtitles-octopus-worker-legacy.js`, onError() { + // HACK: Clear JavascriptSubtitlesOctopus: it gets disposed when an error occurs + htmlVideoPlayer.#currentSubtitlesOctopus = null; + onErrorInternal(htmlVideoPlayer, 'mediadecodeerror'); }, timeOffset: (this._currentPlayOptions.transcodingOffsetTicks || 0) / 10000000, From 9f6fdfdd7215c724385f8b0ac813787e8e84025a Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Thu, 23 Sep 2021 21:30:59 +0300 Subject: [PATCH 2/3] Destroy the player after destroying JavascriptSubtitlesOctopus --- src/plugins/htmlVideoPlayer/plugin.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/htmlVideoPlayer/plugin.js b/src/plugins/htmlVideoPlayer/plugin.js index cf477bfd9d..f1a0f427d6 100644 --- a/src/plugins/htmlVideoPlayer/plugin.js +++ b/src/plugins/htmlVideoPlayer/plugin.js @@ -675,14 +675,14 @@ function tryRemoveElement(elem) { } onEndedInternal(this, elem, this.onError); - - if (destroyPlayer) { - this.destroy(); - } } this.destroyCustomTrack(elem); + if (destroyPlayer) { + this.destroy(); + } + return Promise.resolve(); } From 50880983cc2e561ff1fa901559bda1b49ea15eef Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Thu, 23 Sep 2021 22:20:03 +0300 Subject: [PATCH 3/3] Give JavascriptSubtitlesOctopus time to dispose itself --- src/plugins/htmlVideoPlayer/plugin.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/htmlVideoPlayer/plugin.js b/src/plugins/htmlVideoPlayer/plugin.js index f1a0f427d6..eeef1d5181 100644 --- a/src/plugins/htmlVideoPlayer/plugin.js +++ b/src/plugins/htmlVideoPlayer/plugin.js @@ -1065,7 +1065,10 @@ function tryRemoveElement(elem) { // HACK: Clear JavascriptSubtitlesOctopus: it gets disposed when an error occurs htmlVideoPlayer.#currentSubtitlesOctopus = null; - onErrorInternal(htmlVideoPlayer, 'mediadecodeerror'); + // HACK: Give JavascriptSubtitlesOctopus time to dispose itself + setTimeout(() => { + onErrorInternal(htmlVideoPlayer, 'mediadecodeerror'); + }, 0); }, timeOffset: (this._currentPlayOptions.transcodingOffsetTicks || 0) / 10000000,