mirror of
https://github.com/zimplexing/OrionTV.git
synced 2026-02-04 03:36:29 +08:00
Implement back navigation and control visibility in PlayScreen
- Added back navigation functionality using the router in PlayScreen. - Implemented hardware back button handling to toggle controls visibility. - Updated useTVRemoteHandler to show controls on down key press.
This commit is contained in:
20
app/play.tsx
20
app/play.tsx
@@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useRef } from "react";
|
||||
import { View, StyleSheet, TouchableOpacity, ActivityIndicator } from "react-native";
|
||||
import { useLocalSearchParams } from "expo-router";
|
||||
import { View, StyleSheet, TouchableOpacity, ActivityIndicator, BackHandler } from "react-native";
|
||||
import { useLocalSearchParams, useRouter } from "expo-router";
|
||||
import { Video, ResizeMode } from "expo-av";
|
||||
import { useKeepAwake } from "expo-keep-awake";
|
||||
import { ThemedView } from "@/components/ThemedView";
|
||||
@@ -14,6 +14,7 @@ import { useTVRemoteHandler } from "@/hooks/useTVRemoteHandler";
|
||||
|
||||
export default function PlayScreen() {
|
||||
const videoRef = useRef<Video>(null);
|
||||
const router = useRouter();
|
||||
useKeepAwake();
|
||||
const { source, id, episodeIndex, position } = useLocalSearchParams<{
|
||||
source: string;
|
||||
@@ -55,6 +56,21 @@ export default function PlayScreen() {
|
||||
|
||||
const { onScreenPress } = useTVRemoteHandler();
|
||||
|
||||
useEffect(() => {
|
||||
const backAction = () => {
|
||||
if (showControls) {
|
||||
setShowControls(false);
|
||||
return true;
|
||||
}
|
||||
router.back();
|
||||
return true;
|
||||
};
|
||||
|
||||
const backHandler = BackHandler.addEventListener("hardwareBackPress", backAction);
|
||||
|
||||
return () => backHandler.remove();
|
||||
}, [showControls, showEpisodeModal, setShowControls, setShowEpisodeModal, router]);
|
||||
|
||||
if (!detail && isLoading) {
|
||||
return (
|
||||
<ThemedView style={[styles.container, styles.centered]}>
|
||||
|
||||
@@ -73,6 +73,9 @@ export const useTVRemoteHandler = () => {
|
||||
case "longRight":
|
||||
seek(60000); // 快进60秒
|
||||
break;
|
||||
case "down":
|
||||
setShowControls(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user