1function hasGetUserMedia() {
2 return !!(navigator.mediaDevices &&
3 navigator.mediaDevices.getUserMedia);
4}
5
6if (hasGetUserMedia()) {
7 // Good to go!
8} else {
9 alert('getUserMedia() is not supported by your browser');
10}
1<input type="file" accept="video/*;capture=camcorder">
2<input type="file" accept="audio/*;capture=microphone">
1<device type="media" onchange="update(this.data)"></device>
2<video autoplay></video>
3<script>
4 function update(stream) {
5 document.querySelector('video').src = stream.url;
6 }
7</script>
1<video autoplay></video>
2
3<script>
4const constraints = {
5 video: true
6};
7
8const video = document.querySelector('video');
9
10navigator.mediaDevices.getUserMedia(constraints).
11 then((stream) => {video.srcObject = stream});
12</script>