feat: background

This commit is contained in:
2025-12-10 11:21:49 +01:00
parent 70ace4cc57
commit d92303dd8a
8 changed files with 23 additions and 21 deletions
+13 -13
View File
@@ -40,10 +40,10 @@ const RecordedPlayback = ({ route }) => {
const stopPlayback = useCallback(async () => {
try {
if (audioPlayer?.playing) await audioPlayer.pause?.();
} catch (e) {}
} catch (e) { }
try {
if (videoPlayer?.playing) videoPlayer.pause();
} catch (e) {}
} catch (e) { }
}, [audioPlayer, videoPlayer]);
useEffect(() => {
@@ -52,7 +52,7 @@ const RecordedPlayback = ({ route }) => {
try {
if (audioPlayer && songUrl) await audioPlayer.play?.();
if (videoPlayer) videoPlayer.play();
} catch (e) {}
} catch (e) { }
};
start();
return () => {
@@ -78,7 +78,7 @@ const RecordedPlayback = ({ route }) => {
videoPlayer.currentTime = Math.max(0, (pos || 0) / 1000);
}
}
} catch (e) {}
} catch (e) { }
}, 250);
return () => global.clearInterval(id);
}, [audioPlayer, videoPlayer]);
@@ -90,7 +90,7 @@ const RecordedPlayback = ({ route }) => {
if (audioPlayer && dur > 0)
await audioPlayer.seekTo?.(Math.floor(pos / 1000));
if (videoPlayer) videoPlayer.currentTime = Math.max(0, pos / 1000);
} catch (e) {}
} catch (e) { }
};
const onSeekStart = useCallback(() => {
@@ -100,19 +100,19 @@ const RecordedPlayback = ({ route }) => {
const pauseDuringSeek = useCallback(async () => {
try {
if (audioPlayer?.playing) await audioPlayer.pause?.();
} catch (e) {}
} catch (e) { }
try {
if (videoPlayer?.playing) videoPlayer.pause();
} catch (e) {}
} catch (e) { }
}, [audioPlayer, videoPlayer]);
const resumeAfterSeek = useCallback(async () => {
try {
if (audioPlayer) await audioPlayer.play?.();
} catch (e) {}
} catch (e) { }
try {
if (videoPlayer) videoPlayer.play();
} catch (e) {}
} catch (e) { }
}, [audioPlayer, videoPlayer]);
const sliderProgress = useMemo(() => {
@@ -140,7 +140,7 @@ const RecordedPlayback = ({ route }) => {
try {
const duration = progressInfo?.dur || 0;
const position = progressInfo?.pos || 0;
const isAtEnd = duration > 0 && duration - position < 350;
const isAtEnd = duration > 0 && duration - position < 1000;
const isCurrentlyPlaying =
!!audioPlayer?.playing || !!videoPlayer?.playing;
@@ -159,7 +159,7 @@ const RecordedPlayback = ({ route }) => {
playbackEndedRef.current = false;
if (songUrl && audioPlayer) await audioPlayer.play?.();
if (videoPlayer) videoPlayer.play();
} catch (e) {}
} catch (e) { }
};
return (
@@ -233,7 +233,7 @@ const RecordedPlayback = ({ route }) => {
onPress={async () => {
try {
await stopPlayback();
} catch (e) {}
} catch (e) { }
try {
if (videoUri) {
const info = await FileSystem.getInfoAsync(videoUri);
@@ -242,7 +242,7 @@ const RecordedPlayback = ({ route }) => {
idempotent: true,
});
}
} catch (e) {}
} catch (e) { }
navigate(Routes.RecordPlayback, { project });
}}
/>