Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix:addresses comments - clear track.onended before intentional stop to prevent disconnect toast

dheerajmr015ff613922ffa
diff --git a/src/hooks/useScreenRecorder.ts b/src/hooks/useScreenRecorder.ts
index 8448b8202..556471688 100644
--- a/src/hooks/useScreenRecorder.ts
+++ b/src/hooks/useScreenRecorder.ts
@@ -204,7 +204,10 @@ export function useScreenRecorder(): UseScreenRecorderReturn {
});
if (cancelled) {
- stream.getTracks().forEach((track) => track.stop());
+ stream.getTracks().forEach((track) => {
+ track.onended = null;
+ track.stop();
+ });
return;
}
@@ -244,7 +247,10 @@ export function useScreenRecorder(): UseScreenRecorderReturn {
cancelled = true;
webcamReady.current = false;
if (acquiredStream) {
- acquiredStream.getTracks().forEach((track) => track.stop());
+ acquiredStream.getTracks().forEach((track) => {
+ track.onended = null;
+ track.stop();
+ });
webcamStream.current = null;
}
};
@@ -493,8 +499,6 @@ export function useScreenRecorder(): UseScreenRecorderReturn {
});
}
if (!webcamStream.current) {
- // The useEffect already showed the appropriate error toast
- // (cameraNotFound or cameraBlocked), so just disable the state.
setWebcamEnabledState(false);
}
}