From 00c6d7e1a8f085cda0b00a214c550d17afe649f0 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Sun, 15 May 2022 15:20:46 -0400 Subject: [PATCH] Merge pull request #3643 from dmitrylyzo/fix-tizen5 (cherry picked from commit 08951633445f151cd8396547913411961f54b6b5) Signed-off-by: Joshua Boniface --- src/plugins/htmlVideoPlayer/plugin.js | 30 ++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/plugins/htmlVideoPlayer/plugin.js b/src/plugins/htmlVideoPlayer/plugin.js index e8c174bbd..894cb6700 100644 --- a/src/plugins/htmlVideoPlayer/plugin.js +++ b/src/plugins/htmlVideoPlayer/plugin.js @@ -32,6 +32,26 @@ import profileBuilder from '../../scripts/browserDeviceProfile'; import { getIncludeCorsCredentials } from '../../scripts/settings/webSettings'; import { setBackdropTransparency, TRANSPARENCY_LEVEL } from '../../components/backdrop/backdrop'; +/** + * Returns resolved URL. + * @param {string} url - URL. + * @returns {string} Resolved URL or `url` if resolving failed. + */ +function resolveUrl(url) { + return new Promise((resolve) => { + var xhr = new XMLHttpRequest(); + xhr.open('HEAD', url, true); + xhr.onload = function () { + resolve(xhr.responseURL || url); + }; + xhr.onerror = function (e) { + console.error(e); + resolve(url); + }; + xhr.send(null); + }); +} + /* eslint-disable indent */ function tryRemoveElement(elem) { @@ -1094,7 +1114,15 @@ function tryRemoveElement(elem) { renderAhead: 90 }; import('libass-wasm').then(({default: SubtitlesOctopus}) => { - apiClient.getNamedConfiguration('encoding').then(config => { + Promise.all([ + apiClient.getNamedConfiguration('encoding'), + // Worker in Tizen 5 doesn't resolve relative path with async request + resolveUrl(options.workerUrl), + resolveUrl(options.legacyWorkerUrl) + ]).then(([config, workerUrl, legacyWorkerUrl]) => { + options.workerUrl = workerUrl; + options.legacyWorkerUrl = legacyWorkerUrl; + if (config.EnableFallbackFont) { apiClient.getJSON(fallbackFontList).then((fontFiles = []) => { fontFiles.forEach(font => {