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,26 +297,26 @@ class VideoContentSetup {
const origParent = content.videoElement.parentElement!;
// Populate quality list
let qualityList = content.videojs?.qualityLevels?.();
let qualityNums: number[] | undefined;
if (qualityList && qualityList.length >= 1) {
const s = new Set<number>();
let hasMax = false;
for (let i = 0; i < qualityList?.length; i++) {
const qualityNums: number[] = [];
let hasOriginal = false;
const qualityList = content.videojs?.qualityLevels?.();
if (qualityList?.length) {
for (let i = 0; i < qualityList.length; i++) {
const { width, height, label } = qualityList[i];
s.add(Math.min(width!, height!));
if (label?.includes('max.m3u8')) {
hasMax = true;
}
qualityNums.push(Math.min(width!, height!));
hasOriginal ||= label?.includes('max.m3u8');
}
qualityNums = Array.from(s).sort((a, b) => b - a);
qualityNums.unshift(0);
if (hasMax) qualityNums.unshift(-1);
qualityNums.unshift(-2);
}
// Sort quality list descending
qualityNums.sort((a, b) => b - a);
// 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
const opts: Plyr.Options = {
i18n: {