1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

fix change audio track during playback

This commit is contained in:
Dmitry Lyzo 2023-01-07 21:37:21 +03:00
parent fe65e0c3b3
commit 0ff3cf321c
2 changed files with 20 additions and 15 deletions

View file

@ -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;

View file

@ -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 = [];