Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop / kill WebRTC media stream

How to completely kill the WebRTC media stream?

MediaStream.stop() is not working anymore.

Testing in Chrome 47, Mac OS 10.11.

like image 461
igorpavlov Avatar asked Jan 23 '16 17:01

igorpavlov


People also ask

How do I stop WebRTC streaming?

Use stream. getTracks(). forEach(track => track. stop()); .

How do I stop a stream in Javascript?

Stopping a video stream This works by obtaining the video element's stream from its srcObject property. Then the stream's track list is obtained by calling its getTracks() method. From there, all that remains to do is to iterate over the track list using forEach() and calling each track's stop() method.

What is MediaStreamTrack?

The MediaStreamTrack interface represents a single media track within a stream; typically, these are audio or video tracks, but other track types may exist as well.


1 Answers

Use stream.getTracks().forEach(track => track.stop());.

stream.stop() was deprecated.

like image 136
jib Avatar answered Sep 28 '22 04:09

jib