diff --git a/src/plugins/htmlVideoPlayer/plugin.js b/src/plugins/htmlVideoPlayer/plugin.js index defd931ae0..dab9501ebd 100644 --- a/src/plugins/htmlVideoPlayer/plugin.js +++ b/src/plugins/htmlVideoPlayer/plugin.js @@ -28,7 +28,7 @@ import itemHelper from '../../components/itemHelper'; import Screenfull from 'screenfull'; import globalize from '../../scripts/globalize'; import ServerConnections from '../../components/ServerConnections'; -import profileBuilder from '../../scripts/browserDeviceProfile'; +import profileBuilder, { canPlaySecondaryAudio } from '../../scripts/browserDeviceProfile'; import { getIncludeCorsCredentials } from '../../scripts/settings/webSettings'; import { includesAny } from '../../utils/container.ts'; @@ -1557,15 +1557,9 @@ function tryRemoveElement(elem) { } canSetAudioStreamIndex() { - if (browser.tizen || browser.orsay) { - return true; - } - const video = this.#mediaElement; if (video) { - if (video.audioTracks) { - return true; - } + return canPlaySecondaryAudio(video); } return false; diff --git a/src/scripts/browserDeviceProfile.js b/src/scripts/browserDeviceProfile.js index ebe4e2ef0e..0cd95e154d 100644 --- a/src/scripts/browserDeviceProfile.js +++ b/src/scripts/browserDeviceProfile.js @@ -353,6 +353,23 @@ import browser from './browser'; return 2; } +/** + * Checks if the web engine supports secondary audio. + * @param {HTMLVideoElement} videoTestElement The video test element + * @returns {boolean} _true_ if the web engine supports secondary audio. + */ +export function canPlaySecondaryAudio(videoTestElement) { + // We rely on HTMLMediaElement.audioTracks + // It works in Chrome 79+ with "Experimental Web Platform features" enabled + return !!videoTestElement.audioTracks + // It doesn't work in Firefox 108 even with "media.track.enabled" enabled (it only sees the first audio track) + && !browser.firefox + // It seems to work on Tizen 5.5+ (2020, Chrome 69+). See https://developer.tizen.org/forums/web-application-development/video-tag-not-work-audiotracks + && (browser.tizenVersion >= 5.5 || !browser.tizen) + // Assume webOS 5+ (2020, Chrome 68+) supports secondary audio like Tizen 5.5+ + && (browser.web0sVersion >= 5.0 || !browser.web0sVersion); +} + export default function (options) { options = options || {}; @@ -752,13 +769,7 @@ import browser from './browser'; profile.CodecProfiles = []; - // We rely on HTMLMediaElement.audioTracks - // It works in Chrome 79+ with "Experimental Web Platform features" enabled - // It doesn't work in Firefox 108 even with "media.track.enabled" enabled (it only sees the first audio track) - // It seems to work on Tizen 5.5+ (Chrome 69+). See https://developer.tizen.org/forums/web-application-development/video-tag-not-work-audiotracks - const supportsSecondaryAudio = !!videoTestElement.audioTracks - && !browser.firefox - && (browser.tizenVersion >= 5.5 || !browser.tizen); + const supportsSecondaryAudio = canPlaySecondaryAudio(videoTestElement); const aacCodecProfileConditions = [];