Stop/Close webcam stream which is opened by navigator.mediaDevices.getUserMedia [closed]

I opened a webcam by using the following JavaScript code:

const stream = await navigator.mediaDevices.getUserMedia({ /* ... */ });

Is there any JavaScript code to stop or close the webcam? Thanks everyone.

16 Answers
16

Leave a Comment