mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-15 15:48:05 +00:00
Some checks failed
🤖 Android APK Build / 🏗️ Build Android APK (push) Has been cancelled
🤖 iOS IPA Build / 🏗️ Build iOS IPA (push) Has been cancelled
🔒 Lockfile Consistency Check / 🔍 Check bun.lock and package.json consistency (push) Has been cancelled
🛡️ CodeQL Analysis / 🔎 Analyze with CodeQL (javascript-typescript) (push) Has been cancelled
🏷️🔀Merge Conflict Labeler / 🏷️ Labeling Merge Conflicts (push) Has been cancelled
🕒 Handle Stale Issues / 🗑️ Cleanup Stale Issues (push) Has been cancelled
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import type {
|
|
BaseItemDto,
|
|
MediaSourceInfo,
|
|
} from "@jellyfin/sdk/lib/generated-client";
|
|
import type React from "react";
|
|
import { createContext, type ReactNode, useContext } 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;
|
|
};
|