Help us understand the problem. What is going on with this article?

getUserMediaでオープンしたデバイスを閉じる方法

More than 1 year has passed since last update.

概要

WebRTCでgetUserMedia()を呼び出すとカメラやマイクなどのデバイスがキャプチャ状態になります。
これらのデバイスを解放するにはgetUserMedia()で取得したstreamに対して、以下の処理を行うことで解放することができました。

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

Google Chrome バージョン: 64.0.3282.186

他に適切な方法があればコメントをいただけると幸いです。

参考

MediaDevices.getUserMedia() - Web API インターフェイス | MDN https://developer.mozilla.org/ja/docs/Web/API/MediaDevices/getUserMedia

getUserMedia: select resolution https://webrtc.github.io/samples/src/content/getusermedia/resolution/

yorifuji
通信系SIerでリアルタイム映像通信システムの管理業務の傍ら個人開発をしています。最近はiOSアプリやWebRTCを勉強中。Apple製品が好き。フォローやコメント貰えると嬉しいです😊https://note.com/yorifuji
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした