diff --git a/src/components/appRouter.js b/src/components/appRouter.js index e40875089c..5a89deca54 100644 --- a/src/components/appRouter.js +++ b/src/components/appRouter.js @@ -44,13 +44,7 @@ class AppRouter { }, 0); }); - document.addEventListener('viewshow', () => { - const resolve = this.resolveOnNextShow; - if (resolve) { - this.resolveOnNextShow = null; - resolve(); - } - }); + document.addEventListener('viewshow', () => this.onViewShow()); this.baseRoute = window.location.href.split('?')[0].replace(this.getRequestFile(), ''); // support hashbang @@ -417,6 +411,14 @@ class AppRouter { }); } + onViewShow() { + const resolve = this.resolveOnNextShow; + if (resolve) { + this.resolveOnNextShow = null; + resolve(); + } + } + onForcedLogoutMessageTimeout() { const msg = this.forcedLogoutMsg; this.forcedLogoutMsg = null; @@ -638,7 +640,11 @@ class AppRouter { const ignore = route.dummyRoute === true || this.previousRoute.dummyRoute === true; this.previousRoute = route; - if (ignore) return; + if (ignore) { + // Resolve 'show' promise + this.onViewShow(); + return; + } this.handleRoute(ctx, next, route); }; diff --git a/src/plugins/htmlVideoPlayer/plugin.js b/src/plugins/htmlVideoPlayer/plugin.js index 611240be3e..eeef1d5181 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(); } @@ -1062,7 +1062,13 @@ function tryRemoveElement(elem) { workerUrl: `${appRouter.baseUrl()}/libraries/subtitles-octopus-worker.js`, legacyWorkerUrl: `${appRouter.baseUrl()}/libraries/subtitles-octopus-worker-legacy.js`, onError() { - onErrorInternal(htmlVideoPlayer, 'mediadecodeerror'); + // HACK: Clear JavascriptSubtitlesOctopus: it gets disposed when an error occurs + htmlVideoPlayer.#currentSubtitlesOctopus = null; + + // HACK: Give JavascriptSubtitlesOctopus time to dispose itself + setTimeout(() => { + onErrorInternal(htmlVideoPlayer, 'mediadecodeerror'); + }, 0); }, timeOffset: (this._currentPlayOptions.transcodingOffsetTicks || 0) / 10000000,