Add track sorting to mediainfo and player track selection

This commit is contained in:
Shadowghost 2022-04-06 13:17:46 +02:00
parent dc956eb48c
commit b69b9227c4
3 changed files with 9 additions and 8 deletions

View File

@ -12,6 +12,7 @@ import toast from '../toast/toast';
import { copy } from '../../scripts/clipboard';
import dom from '../../scripts/dom';
import globalize from '../../scripts/globalize';
import itemHelper from '../../components/itemHelper';
import loading from '../loading/loading';
import '../../elements/emby-select/emby-select';
import '../listview/listview.scss';
@ -71,8 +72,8 @@ const attributeDelimiterHtml = layoutManager.tv ? '' : '<span class="hide">: </s
const size = `${(version.Size / (1024 * 1024)).toFixed(0)} MB`;
html += `${createAttribute(globalize.translate('MediaInfoSize'), size)}<br/>`;
}
for (let i = 0, length = version.MediaStreams.length; i < length; i++) {
const stream = version.MediaStreams[i];
version.MediaStreams.sort(itemHelper.sortTracks);
for (const stream of version.MediaStreams) {
if (stream.Type === 'Data') {
continue;
}

View File

@ -3657,7 +3657,7 @@ class PlaybackManager {
if (player.audioTracks) {
const result = player.audioTracks();
if (result) {
return result;
return result.sort(itemHelper.sortTracks);
}
}
@ -3666,14 +3666,14 @@ class PlaybackManager {
const mediaStreams = (mediaSource || {}).MediaStreams || [];
return mediaStreams.filter(function (s) {
return s.Type === 'Audio';
});
}).sort(itemHelper.sortTracks);
}
subtitleTracks(player = this._currentPlayer) {
if (player.subtitleTracks) {
const result = player.subtitleTracks();
if (result) {
return result;
return result.sort(itemHelper.sortTracks);
}
}
@ -3682,7 +3682,7 @@ class PlaybackManager {
const mediaStreams = (mediaSource || {}).MediaStreams || [];
return mediaStreams.filter(function (s) {
return s.Type === 'Subtitle';
});
}).sort(itemHelper.sortTracks);
}
getSupportedCommands(player) {

View File

@ -274,7 +274,7 @@ function renderAudioSelections(page, mediaSources) {
const tracks = mediaSource.MediaStreams.filter(function (m) {
return m.Type === 'Audio';
});
tracks.sort((a, b) => itemHelper.sortTracks(a, b));
tracks.sort(itemHelper.sortTracks);
const select = page.querySelector('.selectAudio');
select.setLabel(globalize.translate('Audio'));
const selectedId = mediaSource.DefaultAudioStreamIndex;
@ -304,7 +304,7 @@ function renderSubtitleSelections(page, mediaSources) {
const tracks = mediaSource.MediaStreams.filter(function (m) {
return m.Type === 'Subtitle';
});
tracks.sort((a, b) => itemHelper.sortTracks(a, b));
tracks.sort(itemHelper.sortTracks);
const select = page.querySelector('.selectSubtitles');
select.setLabel(globalize.translate('Subtitles'));
const selectedId = mediaSource.DefaultSubtitleStreamIndex == null ? -1 : mediaSource.DefaultSubtitleStreamIndex;