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 { TimelineAction, VideoPlayer, VideoPlayerProps } from "./VideoPlayer";
|
||||||
import { useGlobalPlayerStore } from "../../state/pip";
|
import { useGlobalPlayerStore } from "../../state/pip";
|
||||||
import Player from "video.js/dist/types/player";
|
import Player from "video.js/dist/types/player";
|
||||||
import { useIsPlaying } from "../../state/video";
|
import { useIsPlaying } from "../../state/video";
|
||||||
import { QortalGetMetadata } from "../../types/interfaces/resources";
|
import { QortalGetMetadata } from "../../types/interfaces/resources";
|
||||||
|
import { GlobalContext } from "../../context/GlobalProvider";
|
||||||
|
|
||||||
export interface VideoPlayerParentProps {
|
export interface VideoPlayerParentProps {
|
||||||
qortalVideoResource: QortalGetMetadata;
|
qortalVideoResource: QortalGetMetadata;
|
||||||
@ -23,6 +24,7 @@ export const VideoPlayerParent = ({
|
|||||||
onEnded,
|
onEnded,
|
||||||
timelineActions,
|
timelineActions,
|
||||||
}: VideoPlayerParentProps) => {
|
}: VideoPlayerParentProps) => {
|
||||||
|
const context = useContext(GlobalContext)
|
||||||
const playerRef = useRef<Player | null>(null);
|
const playerRef = useRef<Player | null>(null);
|
||||||
const locationRef = useRef<string | null>(null);
|
const locationRef = useRef<string | null>(null);
|
||||||
const videoLocationRef = useRef<null | string>(null);
|
const videoLocationRef = useRef<null | string>(null);
|
||||||
@ -39,7 +41,7 @@ export const VideoPlayerParent = ({
|
|||||||
const isPlaying = isPlayingRef.current;
|
const isPlaying = isPlayingRef.current;
|
||||||
const currentSrc = player?.currentSrc();
|
const currentSrc = player?.currentSrc();
|
||||||
|
|
||||||
if (currentSrc && isPlaying && videoLocationRef.current) {
|
if (context?.enableGlobalVideoFeature && currentSrc && isPlaying && videoLocationRef.current) {
|
||||||
const current = player?.currentTime?.();
|
const current = player?.currentTime?.();
|
||||||
const currentSource = player?.currentType();
|
const currentSource = player?.currentType();
|
||||||
|
|
||||||
@ -54,7 +56,7 @@ export const VideoPlayerParent = ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, []);
|
}, [context?.enableGlobalVideoFeature]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return () => {
|
return () => {
|
||||||
const player = playerRef.current;
|
const player = playerRef.current;
|
||||||
|
@ -28,6 +28,7 @@ interface GlobalContextType {
|
|||||||
identifierOperations: ReturnType<typeof useIdentifiers>;
|
identifierOperations: ReturnType<typeof useIdentifiers>;
|
||||||
persistentOperations: ReturnType<typeof usePersistentStore>;
|
persistentOperations: ReturnType<typeof usePersistentStore>;
|
||||||
indexOperations: ReturnType<typeof useIndexes>;
|
indexOperations: ReturnType<typeof useIndexes>;
|
||||||
|
enableGlobalVideoFeature: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✅ Define Config Type for Hook Options
|
// ✅ Define Config Type for Hook Options
|
||||||
@ -38,6 +39,7 @@ interface GlobalProviderProps {
|
|||||||
auth?: UseAuthProps;
|
auth?: UseAuthProps;
|
||||||
appName: string;
|
appName: string;
|
||||||
publicSalt: string;
|
publicSalt: string;
|
||||||
|
enableGlobalVideoFeature?: boolean
|
||||||
};
|
};
|
||||||
|
|
||||||
toastStyle?: CSSProperties;
|
toastStyle?: CSSProperties;
|
||||||
@ -78,8 +80,9 @@ export const GlobalProvider = ({
|
|||||||
identifierOperations,
|
identifierOperations,
|
||||||
persistentOperations,
|
persistentOperations,
|
||||||
indexOperations,
|
indexOperations,
|
||||||
|
enableGlobalVideoFeature: config?.enableGlobalVideoFeature || false
|
||||||
}),
|
}),
|
||||||
[auth, lists, appInfo, identifierOperations, persistentOperations]
|
[auth, lists, appInfo, identifierOperations, persistentOperations, config?.enableGlobalVideoFeature]
|
||||||
);
|
);
|
||||||
const { clearOldProgress } = useProgressStore();
|
const { clearOldProgress } = useProgressStore();
|
||||||
|
|
||||||
@ -90,8 +93,10 @@ export const GlobalProvider = ({
|
|||||||
return (
|
return (
|
||||||
|
|
||||||
<GlobalContext.Provider value={contextValue}>
|
<GlobalContext.Provider value={contextValue}>
|
||||||
|
{config?.enableGlobalVideoFeature && (
|
||||||
<GlobalPipPlayer />
|
<GlobalPipPlayer />
|
||||||
|
)}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user