tangled
alpha
login
or
join now
stream.place
/
streamplace
74
fork
atom
Live video on the AT Protocol
74
fork
atom
overview
issues
1
pulls
pipelines
add camera useEffect cleanup function
Jordan Weatherby
2 weeks ago
4e80d90a
cccc4fce
+11
1 changed file
expand all
collapse all
unified
split
js
components
src
components
mobile-player
video-async.native.tsx
+11
js/components/src/components/mobile-player/video-async.native.tsx
···
315
const localMediaStream = lms;
316
317
useEffect(() => {
0
0
318
if (ingestMediaSource === IngestMediaSource.DISPLAY) {
319
mediaDevices
320
.getDisplayMedia()
321
.then((stream: WebRTCMediaStream) => {
0
322
console.log("display media", stream);
323
setLocalMediaStream(stream);
324
})
···
344
},
345
})
346
.then((stream: WebRTCMediaStream) => {
0
347
setLocalMediaStream(stream);
348
349
let errs: string[] = [];
···
374
);
375
});
376
}
0
0
0
0
0
0
0
377
}, [ingestMediaSource, ingestCamera]);
378
379
useEffect(() => {
···
315
const localMediaStream = lms;
316
317
useEffect(() => {
318
+
let acquiredStream: WebRTCMediaStream | null = null;
319
+
320
if (ingestMediaSource === IngestMediaSource.DISPLAY) {
321
mediaDevices
322
.getDisplayMedia()
323
.then((stream: WebRTCMediaStream) => {
324
+
acquiredStream = stream;
325
console.log("display media", stream);
326
setLocalMediaStream(stream);
327
})
···
347
},
348
})
349
.then((stream: WebRTCMediaStream) => {
350
+
acquiredStream = stream;
351
setLocalMediaStream(stream);
352
353
let errs: string[] = [];
···
378
);
379
});
380
}
381
+
382
+
return () => {
383
+
if (acquiredStream) {
384
+
acquiredStream.getTracks().forEach((track) => track.stop());
385
+
}
386
+
setLocalMediaStream(null);
387
+
};
388
}, [ingestMediaSource, ingestCamera]);
389
390
useEffect(() => {