refactor: share stream url
This commit is contained in:
@@ -1,16 +1,8 @@
|
||||
import { state } from "./state";
|
||||
import { streamUrlForMode } from "./source";
|
||||
import { safeLocalStorage } from "./storage";
|
||||
import { loadVideoSource } from "./video";
|
||||
|
||||
// same as mode.ts - could be extracted to shared util
|
||||
const streamUrlForMode = (mode: string, quality?: string): string => {
|
||||
const src = state.modeSources[mode];
|
||||
if (!src?.token) return "";
|
||||
let url = `${state.streamURL}?mode=${encodeURIComponent(mode)}&token=${encodeURIComponent(src.token)}`;
|
||||
if (quality && quality !== "best") url += `&quality=${encodeURIComponent(quality)}`;
|
||||
return url;
|
||||
};
|
||||
|
||||
/**
|
||||
* Switches video quality (resolution).
|
||||
* Persists preference to localStorage.
|
||||
|
||||
Reference in New Issue
Block a user