Skip to content

Commit 7132208

Browse files
authored
Stop the screen recording when the user stops sharing.
When the browsers 'stop sharing' button is clicked, the recording doesn't get stopped. The user has to click the stop button in the app UI.
1 parent 283058c commit 7132208

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ export function useReactMediaRecorder({
8585
const stream = (await window.navigator.mediaDevices.getDisplayMedia({
8686
video: video || true,
8787
})) as MediaStream;
88+
stream.getVideoTracks()[0].addEventListener("ended", () => {
89+
stopRecording();
90+
});
8891
if (audio) {
8992
const audioStream = await window.navigator.mediaDevices.getUserMedia({
9093
audio,

0 commit comments

Comments
 (0)