From f14606e579a12f56104605d17d1979bab99e2a8a Mon Sep 17 00:00:00 2001 From: Jelle van Snik Date: Wed, 8 Feb 2023 22:57:40 +0100 Subject: [PATCH] remove old --- __old/DecoratedVideoPlayer.tsx | 184 --------------- __old/VideoContext.tsx | 98 -------- __old/VideoPlayer.tsx | 69 ------ __old/controls/AirplayControl.tsx | 26 -- __old/controls/BackdropControl.tsx | 89 ------- __old/controls/ChromeCastControl.tsx | 15 -- __old/controls/FullscreenControl.tsx | 28 --- __old/controls/LoadingControl.tsx | 12 - __old/controls/MiddlePauseControl.tsx | 28 --- __old/controls/MobileCenterControl.tsx | 20 -- __old/controls/PageTitleControl.tsx | 23 -- __old/controls/PauseControl.tsx | 30 --- __old/controls/ProgressControl.tsx | 77 ------ __old/controls/ProgressListenerControl.tsx | 41 ---- __old/controls/QualityDisplayControl.tsx | 14 -- __old/controls/SeriesSelectionControl.tsx | 194 --------------- __old/controls/ShowControl.tsx | 69 ------ __old/controls/ShowTitleControl.tsx | 15 -- __old/controls/SkipTime.tsx | 47 ---- __old/controls/SourceControl.tsx | 27 --- __old/controls/SourceSelectionControl.tsx | 185 --------------- __old/controls/TimeControl.tsx | 42 ---- __old/controls/VolumeControl.tsx | 86 ------- __old/hooks/controlVideo.ts | 204 ---------------- __old/hooks/useCurrentSeriesEpisodeInfo.ts | 33 --- __old/hooks/useVideoPlayer.ts | 262 --------------------- __old/hooks/utils.ts | 8 - __old/hooks/volumeStore.ts | 25 -- __old/parts/VideoErrorBoundary.tsx | 83 ------- __old/parts/VideoPlayerError.tsx | 36 --- __old/parts/VideoPlayerHeader.tsx | 68 ------ __old/parts/VideoPlayerIconButton.tsx | 27 --- __old/parts/VideoPopout.tsx | 60 ----- 33 files changed, 2225 deletions(-) delete mode 100644 __old/DecoratedVideoPlayer.tsx delete mode 100644 __old/VideoContext.tsx delete mode 100644 __old/VideoPlayer.tsx delete mode 100644 __old/controls/AirplayControl.tsx delete mode 100644 __old/controls/BackdropControl.tsx delete mode 100644 __old/controls/ChromeCastControl.tsx delete mode 100644 __old/controls/FullscreenControl.tsx delete mode 100644 __old/controls/LoadingControl.tsx delete mode 100644 __old/controls/MiddlePauseControl.tsx delete mode 100644 __old/controls/MobileCenterControl.tsx delete mode 100644 __old/controls/PageTitleControl.tsx delete mode 100644 __old/controls/PauseControl.tsx delete mode 100644 __old/controls/ProgressControl.tsx delete mode 100644 __old/controls/ProgressListenerControl.tsx delete mode 100644 __old/controls/QualityDisplayControl.tsx delete mode 100644 __old/controls/SeriesSelectionControl.tsx delete mode 100644 __old/controls/ShowControl.tsx delete mode 100644 __old/controls/ShowTitleControl.tsx delete mode 100644 __old/controls/SkipTime.tsx delete mode 100644 __old/controls/SourceControl.tsx delete mode 100644 __old/controls/SourceSelectionControl.tsx delete mode 100644 __old/controls/TimeControl.tsx delete mode 100644 __old/controls/VolumeControl.tsx delete mode 100644 __old/hooks/controlVideo.ts delete mode 100644 __old/hooks/useCurrentSeriesEpisodeInfo.ts delete mode 100644 __old/hooks/useVideoPlayer.ts delete mode 100644 __old/hooks/utils.ts delete mode 100644 __old/hooks/volumeStore.ts delete mode 100644 __old/parts/VideoErrorBoundary.tsx delete mode 100644 __old/parts/VideoPlayerError.tsx delete mode 100644 __old/parts/VideoPlayerHeader.tsx delete mode 100644 __old/parts/VideoPlayerIconButton.tsx delete mode 100644 __old/parts/VideoPopout.tsx 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 ( -