diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 9f9be018b3..72a13043e9 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -36,6 +36,7 @@ - [MrTimscampi](https://github.com/MrTimscampi) - [ConfusedPolarBear](https://github.com/ConfusedPolarBear) - [Sarab Singh](https://github.com/sarab97) + - [DesertCookie](https://github.com/desertcookie) - [GuilhermeHideki](https://github.com/GuilhermeHideki) - [Andrei Oanca](https://github.com/OancaAndrei) - [Cromefire_](https://github.com/cromefire) diff --git a/src/controllers/itemDetails/index.js b/src/controllers/itemDetails/index.js index bcf681b50a..63eac6abce 100644 --- a/src/controllers/itemDetails/index.js +++ b/src/controllers/itemDetails/index.js @@ -171,7 +171,30 @@ function renderTrackSelections(page, instance, item, forceReload) { return; } - const mediaSources = item.MediaSources; + let mediaSources = item.MediaSources; + + const resolutionNames = []; + const sourceNames = []; + mediaSources.forEach(function (v) { + (v.Name.endsWith('p') || v.Name.endsWith('i')) && !Number.isNaN(parseInt(v.Name, 10)) ? resolutionNames.push(v) : sourceNames.push(v); + }); + + resolutionNames.sort((a, b) => parseInt(b.Name, 10) - parseInt(a.Name, 10)); + sourceNames.sort(function(a, b) { + const nameA = a.Name.toUpperCase(); + const nameB = b.Name.toUpperCase(); + if (nameA < nameB) { + return -1; + } else if (nameA > nameB) { + return 1; + } + return 0; + }); + + mediaSources = []; + resolutionNames.forEach(v => mediaSources.push(v)); + sourceNames.forEach(v => mediaSources.push(v)); + instance._currentPlaybackMediaSources = mediaSources; page.querySelector('.trackSelections').classList.remove('hide');