forked from Ninjalama/streamyfin_mirror
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import { TrackInfo } from "@/modules/vlc-player";
|
|
import {
|
|
BaseItemDto,
|
|
MediaSourceInfo,
|
|
} from "@jellyfin/sdk/lib/generated-client";
|
|
import React, { createContext, useContext, useState, ReactNode } from "react";
|
|
|
|
interface ControlContextProps {
|
|
item: BaseItemDto;
|
|
mediaSource: MediaSourceInfo | null | undefined;
|
|
isVideoLoaded: boolean | undefined;
|
|
}
|
|
|
|
const ControlContext = createContext<ControlContextProps | undefined>(
|
|
undefined
|
|
);
|
|
|
|
interface ControlProviderProps {
|
|
children: ReactNode;
|
|
item: BaseItemDto;
|
|
mediaSource: MediaSourceInfo | null | undefined;
|
|
isVideoLoaded: boolean | undefined;
|
|
}
|
|
|
|
export const ControlProvider: React.FC<ControlProviderProps> = ({
|
|
children,
|
|
item,
|
|
mediaSource,
|
|
isVideoLoaded,
|
|
}) => {
|
|
return (
|
|
<ControlContext.Provider value={{ item, mediaSource, isVideoLoaded }}>
|
|
{children}
|
|
</ControlContext.Provider>
|
|
);
|
|
};
|
|
|
|
export const useControlContext = () => {
|
|
const context = useContext(ControlContext);
|
|
if (context === undefined) {
|
|
throw new Error("useControlContext must be used within a ControlProvider");
|
|
}
|
|
return context;
|
|
};
|