Stop command

This commit is contained in:
Koper
2023-07-20 15:54:28 +07:00
parent 18da114182
commit 71e5df5dac
2 changed files with 7 additions and 7 deletions

View File

@@ -19,15 +19,12 @@ const App = () => {
.getUserMedia({ audio: true })
.then(setStream)
.catch((err) => console.error(err));
} else if (!recording) {
if (stream) {
const tracks = stream.getTracks();
tracks.forEach((track) => track.stop());
setStream(null);
}
} else if (!recording && serverData.peer) {
serverData.peer.send(JSON.stringify({ cmd: 'STOP' }));
}
};
const serverData = useWebRTC(stream, setIsRecording);
return (