File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
vim--ai-scribe--react/src/components/organisms/ai-scribe-demo Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { useState, useEffect } from "react";
33import { useVimOsContext } from "@/providers/VimOSContext" ;
44
55export const useRecorder = ( ) => {
6+ const [ stream , setStream ] = useState < MediaStream | null > ( null ) ;
67 const [ isPaused , setIsPaused ] = useState ( false ) ;
78 const [ isRecording , setIsRecording ] = useState ( false ) ;
89 const [ recordingTime , setRecordingTime ] = useState ( 0 ) ;
@@ -20,7 +21,8 @@ export const useRecorder = () => {
2021
2122 const simulateRecording = useCallback ( async ( ) => {
2223 try {
23- await navigator . mediaDevices . getUserMedia ( { audio : true } ) ;
24+ const stream = await navigator . mediaDevices . getUserMedia ( { audio : true } ) ;
25+ setStream ( stream ) ;
2426 // Show the VimOS microphone badge to indicate active recording
2527 vimOS ?. hub ?. microphoneBadge ?. show ?.( ) ;
2628 setIsRecording ( true ) ;
@@ -34,12 +36,15 @@ export const useRecorder = () => {
3436 } , [ vimOS ] ) ;
3537
3638 const stopRecording = useCallback ( ( ) => {
39+ if ( stream ) {
40+ stream . getTracks ( ) . forEach ( ( track ) => track . stop ( ) ) ;
41+ }
3742 setIsRecording ( false ) ;
3843 setIsPaused ( false ) ;
3944 setRecordingTime ( 0 ) ;
4045 // Hide the VimOS microphone badge when recording stops
4146 vimOS ?. hub ?. microphoneBadge ?. hide ?.( ) ;
42- } , [ vimOS ] ) ;
47+ } , [ vimOS , stream ] ) ;
4348
4449 return {
4550 isPaused,
You can’t perform that action at this time.
0 commit comments