From 95a142f8fe3ea2c2f15f2cc9f72d5d2b39c76885 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Tue, 14 Sep 2021 13:52:32 +0300 Subject: [PATCH 1/5] Add webOS version detection --- src/scripts/browser.js | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/scripts/browser.js b/src/scripts/browser.js index 672ef23fd4..a8f5759ad7 100644 --- a/src/scripts/browser.js +++ b/src/scripts/browser.js @@ -109,6 +109,39 @@ function iOSversion() { return []; } +function web0sVersion(browser) { + // Detect webOS version by web engine version + + if (browser.chrome) { + 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 - assume 1'); + + // Let's assume that we have 1. + return 1; +} + let _supportsCssAnimation; let _supportsCssAnimationWithPrefix; function supportsCssAnimation(allowPrefix) { @@ -251,14 +284,16 @@ browser.tizen = userAgent.toLowerCase().indexOf('tizen') !== -1 || window.tizen browser.web0s = isWeb0s(); browser.edgeUwp = browser.edge && (userAgent.toLowerCase().indexOf('msapphost') !== -1 || userAgent.toLowerCase().indexOf('webview') !== -1); -if (!browser.tizen) { - browser.orsay = userAgent.toLowerCase().indexOf('smarthub') !== -1; -} else { +if (browser.web0s) { + browser.web0sVersion = web0sVersion(browser); +} else if (browser.tizen) { // UserAgent string contains 'Safari' and 'safari' is set by matched browser, but we only want 'tizen' to be true delete browser.safari; const v = (navigator.appVersion).match(/Tizen (\d+).(\d+)/); browser.tizenVersion = parseInt(v[1]); +} else { + browser.orsay = userAgent.toLowerCase().indexOf('smarthub') !== -1; } if (browser.edgeUwp) { From b0304d28d2bf2171bc6ce8586b866c76c87c8d49 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Tue, 14 Sep 2021 22:34:53 +0300 Subject: [PATCH 2/5] Disable DTS on webOS 5+ --- src/scripts/browserDeviceProfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scripts/browserDeviceProfile.js b/src/scripts/browserDeviceProfile.js index cc6ef63332..a8edd5cfc3 100644 --- a/src/scripts/browserDeviceProfile.js +++ b/src/scripts/browserDeviceProfile.js @@ -389,8 +389,8 @@ import browser from './browser'; let supportsDts = browser.tizen || browser.web0s || options.supportsDts || 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) - if (browser.tizenVersion >= 4) { + // DTS audio is not supported by Samsung TV 2018+ (Tizen 4.0+) and LG TV 2020+ (webOS 5.0+) models + if (browser.tizenVersion >= 4 || browser.web0sVersion >= 5) { supportsDts = false; } From 9093a32fe09d4c84f5029ca659333b6050f5d827 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Sat, 18 Sep 2021 01:27:24 +0300 Subject: [PATCH 3/5] Add version detection for webOS built-in browser (NetCast) --- src/scripts/browser.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/scripts/browser.js b/src/scripts/browser.js index a8f5759ad7..d0d9b5a551 100644 --- a/src/scripts/browser.js +++ b/src/scripts/browser.js @@ -113,6 +113,34 @@ 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 + + const match = /smarttv[ /]([\w.]+)/.exec(userAgent); + + if (match?.length > 1) { + const version = parseInt(match[1].split('.')[0], 10); + + // FIXME: Add webOS 5 and 6 + + if (version >= 10) { + return 4; + } else if (version >= 6) { + if (browser.versionMajor >= 38) { + return 3; + } else { + return 2; + } + } else if (version >= 5) { + return 1; + } + } + } + + // The next is only valid for the app, but may also work for the browser of older models + if (browser.versionMajor >= 79) { return 6; } else if (browser.versionMajor >= 68) { From 0f4d449545622b38c07f0362aef5c77641b67018 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Sat, 25 Sep 2021 13:36:55 +0300 Subject: [PATCH 4/5] Skip webOS version detection for built-in browser (NetCast) as unreliable --- src/scripts/browser.js | 28 ++++++---------------------- src/scripts/browserDeviceProfile.js | 2 +- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/scripts/browser.js b/src/scripts/browser.js index d0d9b5a551..af0a72ffe4 100644 --- a/src/scripts/browser.js +++ b/src/scripts/browser.js @@ -117,29 +117,14 @@ function web0sVersion(browser) { 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 - const match = /smarttv[ /]([\w.]+)/.exec(userAgent); + console.warn('Unable to detect webOS version - NetCast'); - if (match?.length > 1) { - const version = parseInt(match[1].split('.')[0], 10); - - // FIXME: Add webOS 5 and 6 - - if (version >= 10) { - return 4; - } else if (version >= 6) { - if (browser.versionMajor >= 38) { - return 3; - } else { - return 2; - } - } else if (version >= 5) { - return 1; - } - } + return undefined; } - // The next is only valid for the app, but may also work for the browser of older models + // The next is only valid for the app if (browser.versionMajor >= 79) { return 6; @@ -164,10 +149,9 @@ function web0sVersion(browser) { return 1; } - console.error('Unable to detect webOS version - assume 1'); + console.error('Unable to detect webOS version'); - // Let's assume that we have 1. - return 1; + return undefined; } let _supportsCssAnimation; diff --git a/src/scripts/browserDeviceProfile.js b/src/scripts/browserDeviceProfile.js index a8edd5cfc3..28cc0dcef0 100644 --- a/src/scripts/browserDeviceProfile.js +++ b/src/scripts/browserDeviceProfile.js @@ -387,7 +387,7 @@ import browser from './browser'; 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 = browser.tizen || browser.web0sVersion || options.supportsDts || videoTestElement.canPlayType('video/mp4; codecs="dts-"').replace(/no/, '') || videoTestElement.canPlayType('video/mp4; codecs="dts+"').replace(/no/, ''); // DTS audio is not supported by Samsung TV 2018+ (Tizen 4.0+) and LG TV 2020+ (webOS 5.0+) models if (browser.tizenVersion >= 4 || browser.web0sVersion >= 5) { From 59bd00a92aeb052f5a77dabd4c5c360932a5b09a Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Sat, 25 Sep 2021 13:50:47 +0300 Subject: [PATCH 5/5] Don't override explicitly defined DTS support --- src/scripts/browserDeviceProfile.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/scripts/browserDeviceProfile.js b/src/scripts/browserDeviceProfile.js index 28cc0dcef0..57819e8ec3 100644 --- a/src/scripts/browserDeviceProfile.js +++ b/src/scripts/browserDeviceProfile.js @@ -387,11 +387,14 @@ import browser from './browser'; videoAudioCodecs.push('mp2'); } - let supportsDts = browser.tizen || browser.web0sVersion || 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 is not supported by Samsung TV 2018+ (Tizen 4.0+) and LG TV 2020+ (webOS 5.0+) models - if (browser.tizenVersion >= 4 || browser.web0sVersion >= 5) { - supportsDts = false; + // DTS audio is not supported by Samsung TV 2018+ (Tizen 4.0+) and LG TV 2020+ (webOS 5.0+) models + if (browser.tizenVersion >= 4 || browser.web0sVersion >= 5) { + supportsDts = false; + } } if (supportsDts) {