Skip to content

Commit

Permalink
video: allow switch to direct on Safari (fix #650)
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Patil <[email protected]>
  • Loading branch information
pulsejet committed Nov 1, 2023
1 parent 44c3ed1 commit 973cd86
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/components/viewer/PsVideo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 973cd86

Please sign in to comment.