From 97ac8c3f9f6b50bd5ff4c38091819d6af03c8ef6 Mon Sep 17 00:00:00 2001 From: PhilReact Date: Thu, 26 Jun 2025 22:47:45 +0300 Subject: [PATCH] added enableGlobalVideoFeature --- src/components/VideoPlayer/VideoPlayerParent.tsx | 8 +++++--- src/context/GlobalProvider.tsx | 11 ++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/components/VideoPlayer/VideoPlayerParent.tsx b/src/components/VideoPlayer/VideoPlayerParent.tsx index f76cefb..0206677 100644 --- a/src/components/VideoPlayer/VideoPlayerParent.tsx +++ b/src/components/VideoPlayer/VideoPlayerParent.tsx @@ -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(null); const locationRef = useRef(null); const videoLocationRef = useRef(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; diff --git a/src/context/GlobalProvider.tsx b/src/context/GlobalProvider.tsx index 2995e53..fba3445 100644 --- a/src/context/GlobalProvider.tsx +++ b/src/context/GlobalProvider.tsx @@ -28,6 +28,7 @@ interface GlobalContextType { identifierOperations: ReturnType; persistentOperations: ReturnType; indexOperations: ReturnType; + 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 ( - - + {config?.enableGlobalVideoFeature && ( + + )} +