chore: merge things

This commit is contained in:
Fredrik Burmester
2024-11-10 10:11:00 +01:00
parent 5e91f45e3d
commit d95833335e
6 changed files with 35 additions and 25 deletions

View File

@@ -2,7 +2,6 @@ import { Text } from "@/components/common/Text";
import { Loader } from "@/components/Loader";
import AlbumCover from "@/components/posters/AlbumCover";
import { Controls } from "@/components/video-player/Controls";
import { useAndroidNavigationBar } from "@/hooks/useAndroidNavigationBar";
import { useOrientation } from "@/hooks/useOrientation";
import { useOrientationSettings } from "@/hooks/useOrientationSettings";
import { useWebSocket } from "@/hooks/useWebsockets";
@@ -276,7 +275,6 @@ export default function page() {
useOrientation();
useOrientationSettings();
useAndroidNavigationBar();
useWebSocket({
isPlaying: isPlaying,

View File

@@ -38,6 +38,16 @@ export default function page() {
const isSeeking = useSharedValue(false);
const cacheProgress = useSharedValue(0);
const [embededTextTracks, setEmbededTextTracks] = useState<
{
index: number;
language?: string | undefined;
selected?: boolean | undefined;
title?: string | undefined;
type: any;
}[]
>([]);
const togglePlay = useCallback(async () => {
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
if (isPlaying) {
@@ -57,6 +67,17 @@ export default function page() {
videoRef.current?.pause();
}, [videoRef]);
const pause = useCallback(() => {
videoRef.current?.pause();
}, [videoRef]);
const seek = useCallback(
(seconds: number) => {
videoRef.current?.seek(seconds);
},
[videoRef]
);
useFocusEffect(
useCallback(() => {
play();
@@ -118,9 +139,11 @@ export default function page() {
}}
/>
</Pressable>
<Controls
item={playSettings.item}
videoRef={videoRef}
enableTrickplay={true}
item={playSettings.item}
togglePlay={togglePlay}
isPlaying={isPlaying}
isSeeking={isSeeking}
@@ -131,6 +154,9 @@ export default function page() {
setShowControls={setShowControls}
setIgnoreSafeAreas={setIgnoreSafeAreas}
ignoreSafeAreas={ignoreSafeAreas}
seek={seek}
play={play}
pause={pause}
/>
</View>
);

View File

@@ -1,6 +1,5 @@
import { Controls } from "@/components/video-player/Controls";
import { VlcControls } from "@/components/video-player/VlcControls";
import { useAndroidNavigationBar } from "@/hooks/useAndroidNavigationBar";
import { useOrientation } from "@/hooks/useOrientation";
import { useOrientationSettings } from "@/hooks/useOrientationSettings";
import { VlcPlayerView } from "@/modules/vlc-player";
@@ -23,6 +22,7 @@ import React, {
useState,
} from "react";
import { Pressable, StatusBar, useWindowDimensions, View } from "react-native";
import { SystemBars } from "react-native-edge-to-edge";
import { useSharedValue } from "react-native-reanimated";
import { SelectedTrackType } from "react-native-video";
@@ -35,7 +35,6 @@ export default function page() {
const dimensions = useWindowDimensions();
useOrientation();
useOrientationSettings();
useAndroidNavigationBar();
const [isPlaybackStopped, setIsPlaybackStopped] = useState(false);
const [showControls, setShowControls] = useState(true);
@@ -106,7 +105,6 @@ export default function page() {
useOrientation();
useOrientationSettings();
useAndroidNavigationBar();
const selectedSubtitleTrack = useMemo(() => {
const a = playSettings?.mediaSource?.MediaStreams?.find(
@@ -180,7 +178,7 @@ export default function page() {
}}
className="flex flex-col items-center justify-center"
>
<StatusBar hidden />
<SystemBars hidden />
<Pressable
onPress={() => {
setShowControls(!showControls);
@@ -202,7 +200,7 @@ export default function page() {
/>
</Pressable>
{videoRef.current && (
<VlcControls
<Controls
item={playSettings.item}
videoRef={videoRef}
togglePlay={togglePlay}

View File

@@ -1,7 +1,6 @@
import { Text } from "@/components/common/Text";
import { Loader } from "@/components/Loader";
import { Controls } from "@/components/video-player/Controls";
import { useAndroidNavigationBar } from "@/hooks/useAndroidNavigationBar";
import { useOrientation } from "@/hooks/useOrientation";
import { useOrientationSettings } from "@/hooks/useOrientationSettings";
import { useWebSocket } from "@/hooks/useWebsockets";
@@ -25,6 +24,7 @@ import { useFocusEffect, useLocalSearchParams } from "expo-router";
import { useAtomValue } from "jotai";
import React, { useCallback, useMemo, useRef, useState } from "react";
import { Pressable, StatusBar, useWindowDimensions, View } from "react-native";
import { SystemBars } from "react-native-edge-to-edge";
import { useSharedValue } from "react-native-reanimated";
import Video, {
OnProgressData,
@@ -302,7 +302,6 @@ export default function page() {
useOrientation();
useOrientationSettings();
useAndroidNavigationBar();
useWebSocket({
isPlaying: isPlaying,
@@ -358,7 +357,7 @@ export default function page() {
position: "relative",
}}
>
<StatusBar hidden />
<SystemBars hidden />
<Pressable
onPress={() => {
setShowControls(!showControls);

View File

@@ -2,7 +2,6 @@ import { BITRATES } from "@/components/BitrateSelector";
import { Text } from "@/components/common/Text";
import { Loader } from "@/components/Loader";
import { Controls } from "@/components/video-player/Controls";
import { useAndroidNavigationBar } from "@/hooks/useAndroidNavigationBar";
import { useOrientation } from "@/hooks/useOrientation";
import { useOrientationSettings } from "@/hooks/useOrientationSettings";
import { useWebSocket } from "@/hooks/useWebsockets";
@@ -42,6 +41,7 @@ import {
useWindowDimensions,
View,
} from "react-native";
import { SystemBars } from "react-native-edge-to-edge";
import { useSharedValue } from "react-native-reanimated";
export default function page() {
@@ -267,19 +267,8 @@ export default function page() {
[item?.Id, isPlaying, api, isPlaybackStopped]
);
// useFocusEffect(
// useCallback(() => {
// play();
// return () => {
// stop();
// };
// }, [play, stop])
// );
useOrientation();
useOrientationSettings();
useAndroidNavigationBar();
useWebSocket({
isPlaying: isPlaying,
@@ -338,7 +327,7 @@ export default function page() {
}}
className="flex flex-col items-center justify-center"
>
<StatusBar hidden />
<SystemBars hidden />
<Pressable
onPress={() => {
setShowControls(!showControls);

View File

@@ -608,7 +608,7 @@ extension VlcPlayerView: VLCMediaPlayerDelegate {
guard let player = self.mediaPlayer else { return }
let currentTimeMs = player.time.intValue
let remainingTimeMs = player.remainingTime
// let remainingTimeMs = player.remainingTime
let durationMs = player.media?.length.intValue ?? 0
// print("currentTimeMs: \(currentTimeMs) RemainingTimeMs: \(remainingTimeMs)")