diff --git a/__old/DecoratedVideoPlayer.tsx b/__old/DecoratedVideoPlayer.tsx deleted file mode 100644 index 700b0149..00000000 --- a/__old/DecoratedVideoPlayer.tsx +++ /dev/null @@ -1,184 +0,0 @@ -import { DetailedMeta } from "@/backend/metadata/getmeta"; -import { useIsMobile } from "@/hooks/useIsMobile"; -import { useCallback, useRef, useState } from "react"; -import { CSSTransition } from "react-transition-group"; -import { AirplayControl } from "./controls/AirplayControl"; -import { BackdropControl } from "./controls/BackdropControl"; -import { ChromeCastControl } from "./controls/ChromeCastControl"; -import { FullscreenControl } from "./controls/FullscreenControl"; -import { LoadingControl } from "./controls/LoadingControl"; -import { MiddlePauseControl } from "./controls/MiddlePauseControl"; -import { MobileCenterControl } from "./controls/MobileCenterControl"; -import { PageTitleControl } from "./controls/PageTitleControl"; -import { PauseControl } from "./controls/PauseControl"; -import { ProgressControl } from "./controls/ProgressControl"; -import { QualityDisplayControl } from "./controls/QualityDisplayControl"; -import { SeriesSelectionControl } from "./controls/SeriesSelectionControl"; -import { ShowTitleControl } from "./controls/ShowTitleControl"; -import { SkipTime } from "./controls/SkipTime"; -import { SourceSelectionControl } from "./controls/SourceSelectionControl"; -import { TimeControl } from "./controls/TimeControl"; -import { VolumeControl } from "./controls/VolumeControl"; -import { VideoPlayerError } from "./parts/VideoPlayerError"; -import { VideoPlayerHeader } from "./parts/VideoPlayerHeader"; -import { useVideoPlayerState } from "./VideoContext"; -import { VideoPlayer, VideoPlayerProps } from "./VideoPlayer"; - -interface DecoratedVideoPlayerProps { - media?: DetailedMeta; - onGoBack?: () => void; -} - -function LeftSideControls() { - const { videoState } = useVideoPlayerState(); - - const handleMouseEnter = useCallback(() => { - videoState.setLeftControlsHover(true); - }, [videoState]); - const handleMouseLeave = useCallback(() => { - videoState.setLeftControlsHover(false); - }, [videoState]); - - return ( - <> -
- - - - -
- - - ); -} - -export function DecoratedVideoPlayer( - props: VideoPlayerProps & DecoratedVideoPlayerProps -) { - const top = useRef(null); - const center = useRef(null); - const bottom = useRef(null); - const [show, setShow] = useState(false); - const { isMobile } = useIsMobile(); - - const onBackdropChange = useCallback( - (showing: boolean) => { - setShow(showing); - }, - [setShow] - ); - - return ( - - - - -
- -
-
- -
- {isMobile ? ( - -
- -
-
- ) : ( - "" - )} - -
- -
-
- -
-
- {isMobile && } - -
-
- {isMobile ? ( -
-
-
- - -
- -
- ) : ( - <> - -
- - - - - - - - )} -
-
- - - {props.children} - - - ); -} diff --git a/__old/VideoContext.tsx b/__old/VideoContext.tsx deleted file mode 100644 index 10941206..00000000 --- a/__old/VideoContext.tsx +++ /dev/null @@ -1,98 +0,0 @@ -import { MWStreamQuality, MWStreamType } from "@/backend/helpers/streams"; -import React, { - createContext, - MutableRefObject, - useContext, - useEffect, - useReducer, -} from "react"; -import { - initialPlayerState, - PlayerContext, - useVideoPlayer, -} from "./hooks/useVideoPlayer"; - -interface VideoPlayerContextType { - source: string | null; - sourceType: MWStreamType; - quality: MWStreamQuality; - state: PlayerContext; -} -const initial: VideoPlayerContextType = { - source: null, - sourceType: MWStreamType.MP4, - quality: MWStreamQuality.QUNKNOWN, - state: initialPlayerState, -}; - -type VideoPlayerContextAction = - | { - type: "SET_SOURCE"; - url: string; - sourceType: MWStreamType; - quality: MWStreamQuality; - } - | { - type: "UPDATE_PLAYER"; - state: PlayerContext; - }; - -function videoPlayerContextReducer( - original: VideoPlayerContextType, - action: VideoPlayerContextAction -): VideoPlayerContextType { - const video = { ...original }; - if (action.type === "SET_SOURCE") { - video.source = action.url; - video.sourceType = action.sourceType; - video.quality = action.quality; - return video; - } - if (action.type === "UPDATE_PLAYER") { - video.state = action.state; - return video; - } - - return original; -} - -export const VideoPlayerContext = - createContext(initial); -export const VideoPlayerDispatchContext = createContext< - React.Dispatch ->(null as any); - -export function VideoPlayerContextProvider(props: { - children: React.ReactNode; - player: MutableRefObject; - wrapper: MutableRefObject; -}) { - const { playerState } = useVideoPlayer(props.player, props.wrapper); - const [videoData, dispatch] = useReducer( - videoPlayerContextReducer, - initial - ); - - useEffect(() => { - dispatch({ - type: "UPDATE_PLAYER", - state: playerState, - }); - }, [playerState]); - - return ( - - - {props.children} - - - ); -} - -export function useVideoPlayerState() { - const { state } = useContext(VideoPlayerContext); - - return { - videoState: state, - }; -} diff --git a/__old/VideoPlayer.tsx b/__old/VideoPlayer.tsx deleted file mode 100644 index 4642c5ec..00000000 --- a/__old/VideoPlayer.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import { useGoBack } from "@/hooks/useGoBack"; -import { useVolumeControl } from "@/hooks/useVolumeToggle"; -import { forwardRef, useContext, useEffect, useRef } from "react"; -import { VideoErrorBoundary } from "./parts/VideoErrorBoundary"; -import { - useVideoPlayerState, - VideoPlayerContext, - VideoPlayerContextProvider, -} from "./VideoContext"; - -export interface VideoPlayerProps { - autoPlay?: boolean; - children?: React.ReactNode; -} - -const VideoPlayerInternals = forwardRef< - HTMLVideoElement, - { autoPlay: boolean } ->((props, ref) => { - const video = useContext(VideoPlayerContext); - const didInitialize = useRef<{ source: string | null } | null>(null); - const { videoState } = useVideoPlayerState(); - const { toggleVolume } = useVolumeControl(); - - useEffect(() => { - const value = { source: video.source }; - const hasChanged = value.source !== didInitialize.current?.source; - if (!hasChanged) return; - if (!video.state.hasInitialized || !video.source) return; - video.state.initPlayer(video.source, video.sourceType); - didInitialize.current = value; - }, [didInitialize, video]); - - // muted attribute is required for safari, as they cant change the volume itself - return ( -