Use enum to specify media type

This commit is contained in:
2025-04-03 23:56:18 +02:00
parent f6fcfd354a
commit 50f400b8b9
3 changed files with 23 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
import { matches } from '~/lib/match';
import {matches, MatchMediaType} from '~/lib/match';
import Hls from 'hls.js';
import { UrlReferer } from '~/lib/settings';
import {UrlReferer} from '~/lib/settings';
async function playNative(url: string, domain: string, videoElem: HTMLVideoElement) {
await UrlReferer.set(new URL(url).hostname, domain);
@@ -31,7 +31,7 @@ export async function play(videoElem: HTMLVideoElement) {
const id = urlQuery.get('id') as string;
const url = decodeURIComponent(urlQuery.get('url') as string);
const domain = urlQuery.get('domain') as string;
const urlType = urlQuery.get('urlType') as string;
const urlType = urlQuery.get('urlType') as MatchMediaType;
const match = matches[id];
if (match === undefined) {
@@ -39,9 +39,9 @@ export async function play(videoElem: HTMLVideoElement) {
}
document.title = `Stream Bypass (${domain})`;
if (urlType === 'hls') {
if (urlType === MatchMediaType.Hls) {
await playHls(url, domain, videoElem);
} else if (urlType === 'native') {
} else if (urlType === MatchMediaType.Native) {
await playNative(url, domain, videoElem);
}
}