Skip to content
This repository was archived by the owner on Apr 27, 2021. It is now read-only.

Commit 60fc09e

Browse files
committed
Update gUM still capture sample to current API
Use the latest API for capture using getUserMedia()
1 parent 1029c2b commit 60fc09e

File tree

1 file changed

+8
-23
lines changed

1 file changed

+8
-23
lines changed

s/webrtc-capturestill/capture.js

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,14 @@
2525
photo = document.getElementById('photo');
2626
startbutton = document.getElementById('startbutton');
2727

28-
navigator.getMedia = ( navigator.getUserMedia ||
29-
navigator.webkitGetUserMedia ||
30-
navigator.mozGetUserMedia ||
31-
navigator.msGetUserMedia);
32-
33-
navigator.getMedia(
34-
{
35-
video: true,
36-
audio: false
37-
},
38-
function(stream) {
39-
if (navigator.mozGetUserMedia) {
40-
video.mozSrcObject = stream;
41-
} else {
42-
var vendorURL = window.URL || window.webkitURL;
43-
video.src = vendorURL.createObjectURL(stream);
44-
}
45-
video.play();
46-
},
47-
function(err) {
48-
console.log("An error occured! " + err);
49-
}
50-
);
28+
navigator.mediaDevices.getUserMedia({video: true, audio: false})
29+
.then(function(stream) {
30+
video.srcObject = stream;
31+
video.play();
32+
})
33+
.catch(function(err) {
34+
console.log("An error occurred: " + err);
35+
});
5136

5237
video.addEventListener('canplay', function(ev){
5338
if (!streaming) {

0 commit comments

Comments
 (0)