video: allow switch to direct on Safari (fix #650)
Signed-off-by: Varun Patil <radialapps@gmail.com>monorepo
parent
44c3ed1b86
commit
973cd86c1d
|
@ -297,26 +297,26 @@ 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);
|
|
||||||
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
|
// Create the plyr instance
|
||||||
const opts: Plyr.Options = {
|
const opts: Plyr.Options = {
|
||||||
i18n: {
|
i18n: {
|
||||||
|
|
Loading…
Reference in New Issue