Merge pull request #2971 from jellyfin/webos-dts-support

Fix webOS DTS audio support
This commit is contained in:
Bill Thornton 2021-10-27 00:41:33 -04:00 committed by GitHub
commit b6a13e426e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 7 deletions

View File

@ -109,6 +109,51 @@ function iOSversion() {
return []; return [];
} }
function web0sVersion(browser) {
// Detect webOS version by web engine version
if (browser.chrome) {
const userAgent = navigator.userAgent.toLowerCase();
if (userAgent.indexOf('netcast') !== -1) {
// The built-in browser (NetCast) may have a version that doesn't correspond to the actual web engine
// Since there is no reliable way to detect webOS version, we return an undefined version
console.warn('Unable to detect webOS version - NetCast');
return undefined;
}
// The next is only valid for the app
if (browser.versionMajor >= 79) {
return 6;
} else if (browser.versionMajor >= 68) {
return 5;
} else if (browser.versionMajor >= 53) {
return 4;
} else if (browser.versionMajor >= 38) {
return 3;
} else if (browser.versionMajor >= 34) {
// webOS 2 browser
return 2;
} else if (browser.versionMajor >= 26) {
// webOS 1 browser
return 1;
}
} else if (browser.versionMajor >= 538) {
// webOS 2 app
return 2;
} else if (browser.versionMajor >= 537) {
// webOS 1 app
return 1;
}
console.error('Unable to detect webOS version');
return undefined;
}
let _supportsCssAnimation; let _supportsCssAnimation;
let _supportsCssAnimationWithPrefix; let _supportsCssAnimationWithPrefix;
function supportsCssAnimation(allowPrefix) { function supportsCssAnimation(allowPrefix) {
@ -251,14 +296,16 @@ browser.tizen = userAgent.toLowerCase().indexOf('tizen') !== -1 || window.tizen
browser.web0s = isWeb0s(); browser.web0s = isWeb0s();
browser.edgeUwp = browser.edge && (userAgent.toLowerCase().indexOf('msapphost') !== -1 || userAgent.toLowerCase().indexOf('webview') !== -1); browser.edgeUwp = browser.edge && (userAgent.toLowerCase().indexOf('msapphost') !== -1 || userAgent.toLowerCase().indexOf('webview') !== -1);
if (!browser.tizen) { if (browser.web0s) {
browser.orsay = userAgent.toLowerCase().indexOf('smarthub') !== -1; browser.web0sVersion = web0sVersion(browser);
} else { } else if (browser.tizen) {
// UserAgent string contains 'Safari' and 'safari' is set by matched browser, but we only want 'tizen' to be true // UserAgent string contains 'Safari' and 'safari' is set by matched browser, but we only want 'tizen' to be true
delete browser.safari; delete browser.safari;
const v = (navigator.appVersion).match(/Tizen (\d+).(\d+)/); const v = (navigator.appVersion).match(/Tizen (\d+).(\d+)/);
browser.tizenVersion = parseInt(v[1]); browser.tizenVersion = parseInt(v[1]);
} else {
browser.orsay = userAgent.toLowerCase().indexOf('smarthub') !== -1;
} }
if (browser.edgeUwp) { if (browser.edgeUwp) {

View File

@ -387,11 +387,14 @@ import browser from './browser';
videoAudioCodecs.push('mp2'); videoAudioCodecs.push('mp2');
} }
let supportsDts = browser.tizen || browser.web0s || options.supportsDts || videoTestElement.canPlayType('video/mp4; codecs="dts-"').replace(/no/, '') || videoTestElement.canPlayType('video/mp4; codecs="dts+"').replace(/no/, ''); let supportsDts = options.supportsDts;
if (supportsDts == null) {
supportsDts = browser.tizen || browser.web0sVersion || videoTestElement.canPlayType('video/mp4; codecs="dts-"').replace(/no/, '') || videoTestElement.canPlayType('video/mp4; codecs="dts+"').replace(/no/, '');
// DTS audio not supported in 2018 models (Tizen 4.0) // DTS audio is not supported by Samsung TV 2018+ (Tizen 4.0+) and LG TV 2020+ (webOS 5.0+) models
if (browser.tizenVersion >= 4) { if (browser.tizenVersion >= 4 || browser.web0sVersion >= 5) {
supportsDts = false; supportsDts = false;
}
} }
if (supportsDts) { if (supportsDts) {