mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Additional code review
This commit is contained in:
parent
55d57eedcc
commit
5a9378012c
2 changed files with 26 additions and 10 deletions
|
@ -151,15 +151,17 @@ export default function (view) {
|
|||
trickplayResolution = null;
|
||||
|
||||
const mediaSourceId = currentPlayer.streamInfo.mediaSource.Id;
|
||||
let trickplayResolutions;
|
||||
if (item.Trickplay && (trickplayResolutions = item.Trickplay[mediaSourceId])) {
|
||||
const trickplayResolutions = item.Trickplay?.[mediaSourceId];
|
||||
if (trickplayResolutions) {
|
||||
// Prefer highest resolution <= 20% of total screen resolution width
|
||||
let bestWidth;
|
||||
const maxWidth = window.screen.width * window.devicePixelRatio * 0.2;
|
||||
for (const [, info] of Object.entries(trickplayResolutions)) {
|
||||
if (!bestWidth
|
||||
|| (info.Width < bestWidth && bestWidth > maxWidth) // Objects not guaranteed to be sorted in any order, first width might be > maxWidth.
|
||||
|| (info.Width > bestWidth && info.Width <= maxWidth)) bestWidth = info.Width;
|
||||
|| (info.Width > bestWidth && info.Width <= maxWidth)) {
|
||||
bestWidth = info.Width;
|
||||
}
|
||||
}
|
||||
|
||||
if (bestWidth) trickplayResolution = trickplayResolutions[bestWidth];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue