Fix default audio selection ignoring type

pull/7939/head
Joe Rogers 3 years ago
parent 052a59ac3e
commit 5d66c84f2d
No known key found for this signature in database
GPG Key ID: 0074AD57B8FDBBB4

@ -13,11 +13,11 @@ namespace Emby.Server.Implementations.Library
{ {
public static int? GetDefaultAudioStreamIndex(IReadOnlyList<MediaStream> streams, IReadOnlyList<string> preferredLanguages, bool preferDefaultTrack) public static int? GetDefaultAudioStreamIndex(IReadOnlyList<MediaStream> streams, IReadOnlyList<string> preferredLanguages, bool preferDefaultTrack)
{ {
var sortedStreams = GetSortedStreams(streams, MediaStreamType.Audio, preferredLanguages); var sortedStreams = GetSortedStreams(streams, MediaStreamType.Audio, preferredLanguages).ToList();
if (preferDefaultTrack) if (preferDefaultTrack)
{ {
var defaultStream = streams.FirstOrDefault(i => i.IsDefault); var defaultStream = sortedStreams.FirstOrDefault(i => i.IsDefault);
if (defaultStream != null) if (defaultStream != null)
{ {

@ -27,15 +27,23 @@ public class MediaStreamSelectorTests
{ {
var streams = new MediaStream[] var streams = new MediaStream[]
{ {
new()
{
Index = 0,
Type = MediaStreamType.Video,
IsDefault = true
},
new() new()
{ {
Index = 1, Index = 1,
Type = MediaStreamType.Audio,
Language = "fre", Language = "fre",
IsDefault = true IsDefault = true
}, },
new() new()
{ {
Index = 2, Index = 2,
Type = MediaStreamType.Audio,
Language = "eng", Language = "eng",
IsDefault = false IsDefault = false
} }

Loading…
Cancel
Save