Skip to content

Commit

Permalink
Merge pull request #3 from DmitryMyadzelets/gh-pages
Browse files Browse the repository at this point in the history
Support the newer getUserMedia method
  • Loading branch information
gfwilliams authored Oct 26, 2020
2 parents 2b8ce57 + 0013dc2 commit 2f915f2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@
bpm = document.getElementById("bpm");

// Get the webcam's stream.
navigator.getUserMedia(constraints, startStream, function () {});
if (navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia(constraints)
.then(startStream)
.catch(console.error)
} else {
navigator.getUserMedia(constraints, startStream, function () {});
}
}

function startStream(stream) {
Expand Down

0 comments on commit 2f915f2

Please sign in to comment.