mirror of
https://github.com/Qortal/qapp-core.git
synced 2025-07-12 20:31:21 +00:00
added enableGlobalVideoFeature
This commit is contained in:
parent
98a51c0b5f
commit
97ac8c3f9f
@ -1,9 +1,10 @@
|
||||
import React, { useEffect, useRef } from "react";
|
||||
import React, { useContext, useEffect, useRef } from "react";
|
||||
import { TimelineAction, VideoPlayer, VideoPlayerProps } from "./VideoPlayer";
|
||||
import { useGlobalPlayerStore } from "../../state/pip";
|
||||
import Player from "video.js/dist/types/player";
|
||||
import { useIsPlaying } from "../../state/video";
|
||||
import { QortalGetMetadata } from "../../types/interfaces/resources";
|
||||
import { GlobalContext } from "../../context/GlobalProvider";
|
||||
|
||||
export interface VideoPlayerParentProps {
|
||||
qortalVideoResource: QortalGetMetadata;
|
||||
@ -23,6 +24,7 @@ export const VideoPlayerParent = ({
|
||||
onEnded,
|
||||
timelineActions,
|
||||
}: VideoPlayerParentProps) => {
|
||||
const context = useContext(GlobalContext)
|
||||
const playerRef = useRef<Player | null>(null);
|
||||
const locationRef = useRef<string | null>(null);
|
||||
const videoLocationRef = useRef<null | string>(null);
|
||||
@ -39,7 +41,7 @@ export const VideoPlayerParent = ({
|
||||
const isPlaying = isPlayingRef.current;
|
||||
const currentSrc = player?.currentSrc();
|
||||
|
||||
if (currentSrc && isPlaying && videoLocationRef.current) {
|
||||
if (context?.enableGlobalVideoFeature && currentSrc && isPlaying && videoLocationRef.current) {
|
||||
const current = player?.currentTime?.();
|
||||
const currentSource = player?.currentType();
|
||||
|
||||
@ -54,7 +56,7 @@ export const VideoPlayerParent = ({
|
||||
});
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
}, [context?.enableGlobalVideoFeature]);
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
const player = playerRef.current;
|
||||
|
@ -28,6 +28,7 @@ interface GlobalContextType {
|
||||
identifierOperations: ReturnType<typeof useIdentifiers>;
|
||||
persistentOperations: ReturnType<typeof usePersistentStore>;
|
||||
indexOperations: ReturnType<typeof useIndexes>;
|
||||
enableGlobalVideoFeature: boolean
|
||||
}
|
||||
|
||||
// ✅ Define Config Type for Hook Options
|
||||
@ -38,6 +39,7 @@ interface GlobalProviderProps {
|
||||
auth?: UseAuthProps;
|
||||
appName: string;
|
||||
publicSalt: string;
|
||||
enableGlobalVideoFeature?: boolean
|
||||
};
|
||||
|
||||
toastStyle?: CSSProperties;
|
||||
@ -78,8 +80,9 @@ export const GlobalProvider = ({
|
||||
identifierOperations,
|
||||
persistentOperations,
|
||||
indexOperations,
|
||||
enableGlobalVideoFeature: config?.enableGlobalVideoFeature || false
|
||||
}),
|
||||
[auth, lists, appInfo, identifierOperations, persistentOperations]
|
||||
[auth, lists, appInfo, identifierOperations, persistentOperations, config?.enableGlobalVideoFeature]
|
||||
);
|
||||
const { clearOldProgress } = useProgressStore();
|
||||
|
||||
@ -90,8 +93,10 @@ export const GlobalProvider = ({
|
||||
return (
|
||||
|
||||
<GlobalContext.Provider value={contextValue}>
|
||||
|
||||
{config?.enableGlobalVideoFeature && (
|
||||
<GlobalPipPlayer />
|
||||
)}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user