1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-22 14:57:40 +01:00
smov/__old/controls/SourceControl.tsx

28 lines
723 B
TypeScript
Raw Normal View History

import { MWStreamQuality, MWStreamType } from "@/backend/helpers/streams";
2023-01-17 21:12:39 +01:00
import { useContext, useEffect, useRef } from "react";
2023-01-08 13:15:32 +01:00
import { VideoPlayerDispatchContext } from "../VideoContext";
interface SourceControlProps {
source: string;
type: MWStreamType;
quality: MWStreamQuality;
2023-01-08 13:15:32 +01:00
}
export function SourceControl(props: SourceControlProps) {
const dispatch = useContext(VideoPlayerDispatchContext);
2023-01-17 21:12:39 +01:00
const didInitialize = useRef(false);
2023-01-08 13:15:32 +01:00
useEffect(() => {
2023-01-17 21:12:39 +01:00
if (didInitialize.current) return;
2023-01-08 13:15:32 +01:00
dispatch({
type: "SET_SOURCE",
url: props.source,
2023-01-10 19:53:55 +01:00
sourceType: props.type,
quality: props.quality,
2023-01-08 13:15:32 +01:00
});
2023-01-17 21:12:39 +01:00
didInitialize.current = true;
2023-01-10 19:53:55 +01:00
}, [props, dispatch]);
2023-01-08 13:15:32 +01:00
return null;
}