mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 12:23:24 +00:00
feat: timeout if media doesn't play after one minute
This commit is contained in:
@@ -44,6 +44,7 @@ export const VideoPlayer = () => {
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [resizeMode, setResizeMode] = useState(ResizeMode.CONTAIN);
|
||||
const [shouldPlay, setShouldPlay] = useState(true);
|
||||
const [hasStartedPlaying, setHasStartedPlaying] = useState(false);
|
||||
const router = useRouter();
|
||||
const scale = useSharedValue(1);
|
||||
|
||||
@@ -159,7 +160,17 @@ export const VideoPlayer = () => {
|
||||
|
||||
setIsLoading(true);
|
||||
void initializePlayer();
|
||||
}, [dismissFullscreenPlayer, router, stream]);
|
||||
|
||||
const timeout = setTimeout(() => {
|
||||
if (!hasStartedPlaying) {
|
||||
router.back();
|
||||
}
|
||||
}, 60000);
|
||||
|
||||
return () => {
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
}, [dismissFullscreenPlayer, hasStartedPlaying, router, stream]);
|
||||
|
||||
const onVideoLoadStart = () => {
|
||||
setIsLoading(true);
|
||||
@@ -167,6 +178,7 @@ export const VideoPlayer = () => {
|
||||
|
||||
const onReadyForDisplay = () => {
|
||||
setIsLoading(false);
|
||||
setHasStartedPlaying(true);
|
||||
};
|
||||
|
||||
console.log(videoSrc, isLoading);
|
||||
|
Reference in New Issue
Block a user