# Accessing Your Webcam in HTML5

**URL:** https://forum.kirupa.com/t/accessing-your-webcam-in-html5/352092
**Category:** programming
**Created:** [November 23, 2014, 12:06am UTC](https://forum.kirupa.com/t/accessing-your-webcam-in-html5/352092 "2014-11-23T00:06:38Z")
**Posts on this page:** 1
**Showing post:** 38

<div class="post-metadata">

### Author: ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)
#### Post date: [March 20, 2019, 4:20am UTC](https://forum.kirupa.com/t/accessing-your-webcam-in-html5/352092/38 "2019-03-20T04:20:43Z")

</div>

I think you are on the right _ **track** _ 😄

You may need to set the video source to **null** in addition to calling `stop` on the `track` object. Check out the following snippet:

```
function stop(e) {
  var stream = video.srcObject;
  var tracks = stream.getTracks();

  for (var i = 0; i < tracks.length; i++) {
    var track = tracks[i];
    track.stop();
  }

  video.srcObject = null;
}

```

Here is a working example: [https://www.kirupa.com/snippets/examples/stop\_webcam\_stream.htm](https://www.kirupa.com/snippets/examples/stop_webcam_stream.htm)

Does this help?

Cheers,  
Kirupa

---

_[View the full topic](https://forum.kirupa.com/t/accessing-your-webcam-in-html5/352092)._
