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