10
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

Last updated at Posted at 2018-03-03

概要

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/

10
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?