end recoding if user stopps sharing his screen

This commit is contained in:
MarconLP 2023-04-22 08:59:14 +02:00
parent 9c9f007ecb
commit b2975c96dd
No known key found for this signature in database
GPG key ID: A08A9C8B623F5EA5

View file

@ -70,6 +70,11 @@ export default function Recorder({ closeModal, step, setStep }: Props) {
.getVideoTracks()
.forEach((track) => mediaStream.addTrack(track));
const firstVideoTrack = screenStream.getVideoTracks()[0];
if (firstVideoTrack) {
firstVideoTrack.addEventListener("ended", () => handleStop());
}
setStream(mediaStream);
recorderRef.current = new RecordRTC(mediaStream, { type: "video" });
recorderRef.current.startRecording();