stop audio & go back to home
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { useFocusEffect } from '@react-navigation/native'
|
||||
import useSharedAudioPlayer from '../../hooks/useSharedAudioPlayer'
|
||||
import * as FileSystem from 'expo-file-system'
|
||||
import { VideoView, useVideoPlayer } from 'expo-video'
|
||||
@@ -40,13 +41,21 @@ const RecordedPlayback = ({ route }) => {
|
||||
// Start both players on mount
|
||||
const stopPlayback = useCallback(async () => {
|
||||
try {
|
||||
if (audioPlayer?.playing) await audioPlayer.pause?.()
|
||||
if (audioPlayer) await audioPlayer.pause?.()
|
||||
} catch (e) { }
|
||||
try {
|
||||
if (videoPlayer?.playing) videoPlayer.pause()
|
||||
videoPlayer?.pause?.()
|
||||
} catch (e) { }
|
||||
}, [audioPlayer, videoPlayer])
|
||||
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
return () => {
|
||||
void stopPlayback()
|
||||
}
|
||||
}, [stopPlayback])
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
playbackEndedRef.current = false
|
||||
const start = async () => {
|
||||
@@ -213,7 +222,10 @@ const RecordedPlayback = ({ route }) => {
|
||||
<View style={{ width: '80%', alignSelf: 'center', marginTop: 4, gap: 12 }}>
|
||||
<GradientButton
|
||||
title="Je valide"
|
||||
onPress={() => {
|
||||
onPress={async () => {
|
||||
try {
|
||||
await stopPlayback()
|
||||
} catch (e) { }
|
||||
navigate(Routes.PlaybackDownload, {
|
||||
action: 'playback',
|
||||
uri: videoUri,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useFocusEffect } from '@react-navigation/native'
|
||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { Image, Pressable, Text, View } from 'react-native'
|
||||
import { background, icons } from '../../assets'
|
||||
@@ -54,7 +55,7 @@ const RecordedPlayback = ({ route }) => {
|
||||
|
||||
const stopPlayback = useCallback(async () => {
|
||||
try {
|
||||
if (audioPlayer?.playing) await audioPlayer.pause?.()
|
||||
if (audioPlayer) await audioPlayer.pause?.()
|
||||
} catch { }
|
||||
try {
|
||||
if (videoElRef.current && !videoElRef.current.paused) {
|
||||
@@ -63,6 +64,14 @@ const RecordedPlayback = ({ route }) => {
|
||||
} catch { }
|
||||
}, [audioPlayer])
|
||||
|
||||
useFocusEffect(
|
||||
useCallback(() => {
|
||||
return () => {
|
||||
void stopPlayback()
|
||||
}
|
||||
}, [stopPlayback])
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (!shouldPreserveBlobRef.current) {
|
||||
@@ -363,8 +372,11 @@ const RecordedPlayback = ({ route }) => {
|
||||
>
|
||||
<GradientButton
|
||||
title="Je valide"
|
||||
onPress={() => {
|
||||
onPress={async () => {
|
||||
shouldPreserveBlobRef.current = true
|
||||
try {
|
||||
await stopPlayback()
|
||||
} catch { }
|
||||
navigate(Routes.PlaybackDownload, {
|
||||
action: 'playback',
|
||||
uri: videoUri || null, // peut être null sur web
|
||||
|
||||
Reference in New Issue
Block a user