video: allow switch to direct on Safari (fix #650)

Signed-off-by: Varun Patil <radialapps@gmail.com>
monorepo
Varun Patil 2023-10-31 22:22:21 -07:00
parent 44c3ed1b86
commit 973cd86c1d
1 changed files with 16 additions and 16 deletions

View File

@ -297,25 +297,25 @@ class VideoContentSetup {
const origParent = content.videoElement.parentElement!; const origParent = content.videoElement.parentElement!;
// Populate quality list // Populate quality list
let qualityList = content.videojs?.qualityLevels?.(); const qualityNums: number[] = [];
let qualityNums: number[] | undefined; let hasOriginal = false;
if (qualityList && qualityList.length >= 1) { const qualityList = content.videojs?.qualityLevels?.();
const s = new Set<number>(); if (qualityList?.length) {
let hasMax = false; for (let i = 0; i < qualityList.length; i++) {
for (let i = 0; i < qualityList?.length; i++) {
const { width, height, label } = qualityList[i]; const { width, height, label } = qualityList[i];
s.add(Math.min(width!, height!)); qualityNums.push(Math.min(width!, height!));
hasOriginal ||= label?.includes('max.m3u8');
if (label?.includes('max.m3u8')) {
hasMax = true;
} }
} }
qualityNums = Array.from(s).sort((a, b) => b - a); // Sort quality list descending
qualityNums.unshift(0); qualityNums.sort((a, b) => b - a);
if (hasMax) qualityNums.unshift(-1);
qualityNums.unshift(-2); // These quality options are always available
} // E.g. the qualityList is empty on iOS Safari
if (!staticConfig.getSync('vod_disable')) qualityNums.unshift(0); // adaptive
if (hasOriginal) qualityNums.unshift(-1); // original
if (true) qualityNums.unshift(-2); // direct
// Create the plyr instance // Create the plyr instance
const opts: Plyr.Options = { const opts: Plyr.Options = {