Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
88
rated 0 times [  92] [ 4]  / answers: 1 / hits: 41605  / 10 Years ago, fri, april 25, 2014, 12:00:00

Is it possible to figure out whether a user has a webcam or not using only JavaScript? I don't want to use any plugin for this.


More From » javascript

 Answers
55

You can use a new HTML5 API to check if they give you permission to use the webcam. After all, if they deny permission, they might as well not have a webcam, from the code's perspective.



See navigator.getUserMedia().



EDIT:



navigator.getMedia = ( navigator.getUserMedia || // use the proper vendor prefix
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia);

navigator.getMedia({video: true}, function() {
// webcam is available
}, function() {
// webcam is not available
});

[#71304] Wednesday, April 23, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eanskylerg

Total Points: 524
Total Questions: 107
Total Answers: 100

Location: Colombia
Member since Mon, May 2, 2022
2 Years ago
;