| .. | .. |
|---|
| 10 | 10 | import { stopPlayback } from "../../services/audio"; |
|---|
| 11 | 11 | |
|---|
| 12 | 12 | interface VoiceButtonProps { |
|---|
| 13 | | - onVoiceRecorded: (uri: string) => void; |
|---|
| 13 | + onVoiceRecorded: (uri: string, durationMs?: number) => void; |
|---|
| 14 | 14 | } |
|---|
| 15 | 15 | |
|---|
| 16 | 16 | const VOICE_BUTTON_SIZE = 72; |
|---|
| .. | .. |
|---|
| 98 | 98 | }); |
|---|
| 99 | 99 | const uri = recorder.uri; |
|---|
| 100 | 100 | if (uri) { |
|---|
| 101 | | - onVoiceRecorded(uri); |
|---|
| 101 | + // currentTime is in seconds after stop |
|---|
| 102 | + const durationMs = recorder.currentTime > 0 |
|---|
| 103 | + ? Math.round(recorder.currentTime * 1000) |
|---|
| 104 | + : undefined; |
|---|
| 105 | + onVoiceRecorded(uri, durationMs); |
|---|
| 102 | 106 | } |
|---|
| 103 | 107 | } catch (err) { |
|---|
| 104 | 108 | console.error("Failed to stop recording:", err); |
|---|