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

fix filtering of supported audio tracks

This commit is contained in:
Dmitry Lyzo 2023-01-06 22:15:42 +03:00
parent ea79d2651a
commit a7bd7e30c6
3 changed files with 57 additions and 26 deletions

View file

@ -30,6 +30,7 @@ import globalize from '../../scripts/globalize';
import ServerConnections from '../../components/ServerConnections';
import profileBuilder from '../../scripts/browserDeviceProfile';
import { getIncludeCorsCredentials } from '../../scripts/settings/webSettings';
import { includesAny } from '../../utils/container.ts';
/**
* Returns resolved URL.
@ -602,7 +603,7 @@ function tryRemoveElement(elem) {
/**
* @private
*/
isAudioStreamSupported(stream, deviceProfile) {
isAudioStreamSupported(stream, deviceProfile, container) {
const codec = (stream.Codec || '').toLowerCase();
if (!codec) {
@ -617,15 +618,9 @@ function tryRemoveElement(elem) {
const profiles = deviceProfile.DirectPlayProfiles || [];
return profiles.filter(function (p) {
if (p.Type === 'Video') {
if (!p.AudioCodec) {
return true;
}
return p.AudioCodec.toLowerCase().includes(codec);
}
return false;
return p.Type === 'Video'
&& includesAny((p.Container || '').toLowerCase(), container)
&& includesAny((p.AudioCodec || '').toLowerCase(), codec);
}).length > 0;
}
@ -635,8 +630,11 @@ function tryRemoveElement(elem) {
getSupportedAudioStreams() {
const profile = this.#lastProfile;
return getMediaStreamAudioTracks(this._currentPlayOptions.mediaSource).filter((stream) => {
return this.isAudioStreamSupported(stream, profile);
const mediaSource = this._currentPlayOptions.mediaSource;
const container = mediaSource.Container.toLowerCase();
return getMediaStreamAudioTracks(mediaSource).filter((stream) => {
return this.isAudioStreamSupported(stream, profile, container);
});
}