Last active
September 12, 2018 15:05
-
-
Save rafaelrinaldi/5969890 to your computer and use it in GitHub Desktop.
Lazy way to check if a device supports getUserMedia.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getUserMedia() { | |
// Since sometimes there's API support but stuff doesn't actually work, make a usage test. | |
// Add a fake image file input to memory. | |
var input = $('<input type="file" accept="image/*" capture="camera">'); | |
// Test if input is enabled. | |
return input.is(':enabled'); // `true` if device actually supports getUserMedia API. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tested both on iOS (3.3, 4, 5 and 7) and Android version (2.2, 2.3 and 4.0).