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 [isLoading, setIsLoading] = useState(true);
|
||||||
const [resizeMode, setResizeMode] = useState(ResizeMode.CONTAIN);
|
const [resizeMode, setResizeMode] = useState(ResizeMode.CONTAIN);
|
||||||
const [shouldPlay, setShouldPlay] = useState(true);
|
const [shouldPlay, setShouldPlay] = useState(true);
|
||||||
|
const [hasStartedPlaying, setHasStartedPlaying] = useState(false);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const scale = useSharedValue(1);
|
const scale = useSharedValue(1);
|
||||||
|
|
||||||
@@ -159,7 +160,17 @@ export const VideoPlayer = () => {
|
|||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
void initializePlayer();
|
void initializePlayer();
|
||||||
}, [dismissFullscreenPlayer, router, stream]);
|
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
if (!hasStartedPlaying) {
|
||||||
|
router.back();
|
||||||
|
}
|
||||||
|
}, 60000);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
};
|
||||||
|
}, [dismissFullscreenPlayer, hasStartedPlaying, router, stream]);
|
||||||
|
|
||||||
const onVideoLoadStart = () => {
|
const onVideoLoadStart = () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
@@ -167,6 +178,7 @@ export const VideoPlayer = () => {
|
|||||||
|
|
||||||
const onReadyForDisplay = () => {
|
const onReadyForDisplay = () => {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
setHasStartedPlaying(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(videoSrc, isLoading);
|
console.log(videoSrc, isLoading);
|
||||||
|
Reference in New Issue
Block a user