diff --git a/client/src/components/LiveVoiceCapture.tsx b/client/src/components/LiveVoiceCapture.tsx index ff75c10..513d636 100644 --- a/client/src/components/LiveVoiceCapture.tsx +++ b/client/src/components/LiveVoiceCapture.tsx @@ -44,6 +44,29 @@ export default function LiveVoiceCapture({ const [previewDurationSec, setPreviewDurationSec] = useState(0) const [saving, setSaving] = useState(false) + const previewAudioRef = useRef(null) + + useEffect(() => { + const el = previewAudioRef.current + if (!el) return + + const handleLoadedMetadata = () => { + if (el.duration === Infinity || isNaN(el.duration) || el.duration === 0) { + el.currentTime = 1e10 + const onTimeUpdate = () => { + el.currentTime = 0 + el.removeEventListener('timeupdate', onTimeUpdate) + } + el.addEventListener('timeupdate', onTimeUpdate) + } + } + + el.addEventListener('loadedmetadata', handleLoadedMetadata) + return () => { + el.removeEventListener('loadedmetadata', handleLoadedMetadata) + } + }, [previewUrl]) + const stopStream = useCallback(() => { for (const track of streamRef.current?.getTracks() ?? []) { track.stop() @@ -241,7 +264,7 @@ export default function LiveVoiceCapture({ {phase === 'preview' && previewUrl && ( <> -