Track not stopping
See original GitHub issueSince 1.2.0 upgrade, it looks like stream tracks are not stopping, and the chrome red light is left on even after component unmount. Does anyone have the same issue ?
I tried to stop the stream tracks through a “VideoPreview” function component with no success !
const VideoPreview = ({ stream, status}) => {
const videoRef = useRef()
useEffect(() => {
if (videoRef.current && stream) {
videoRef.current.srcObject = stream;
}
return () => {
if (status == 'stopped') {
stream.getTracks().forEach(track => track.stop())
stream.getTracks().forEach(track => (track.enabled = false))
}
}
}, [stream]);
if (!stream)
return null;
return <video ref={videoRef} id="localVideo" className="video-preview" autoPlay muted/>;
};
Seems like there’s a missing opened stream left unstopped somewhere… Would that be a bug on our side ?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
track.stop is not turning the camera off anymore - Stack Overflow
In your stopStreaming function you only stop the first track in the returned array. If you instead iterate through the tracks you may...
Read more >track.stop() does not stop stream transmission #140 - GitHub
During a call/video call stopping the video stream does nothing and the remote peer follows to hear me.Stream transmission is not stopped.
Read more >MediaStreamTrack.stop() - Web APIs - MDN Web Docs - Mozilla
Calling stop() tells the user agent that the track's source—whatever that source may be, including files, network streams, or a local camera ...
Read more >Animation not stopping when using a Track:Stop()
Hello, i have an issue where my animation wont stop when using Track:Stop(), its a looped animation running in a basic stat training...
Read more >Do Not Stop on Tracks Sign R8-8 | Road Signs - Traffic Signs
R8-8 Do Not Stop On Tracks Sign. Reflective Sheeting on Aluminum. Radius Corners. 3/8" Prepunched Holes. High Intensity and Diamond Grade Meet DOT...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It is not fixed ❗
Use case: if the user “closes” the recorder before starting to record, then there is no way to stop audio tracks because
mediaRecorder.current = null
andpreviewVideo
only contains video tracks (https://github.com/0x006F/react-media-recorder/blob/master/src/index.ts#L240).Maybe consider providing a
stopAudio
render prop OR adding getters formediaRecorder
andmediaStream
.Thanks
Hey @dfabreguette-ap a small patch have been landed via #17 . Can you please update it to the latest and check?
Let me know.