Skip to content

Instantly share code, notes, and snippets.

@rafaelrinaldi
Last active September 12, 2018 15:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaelrinaldi/5969890 to your computer and use it in GitHub Desktop.
Save rafaelrinaldi/5969890 to your computer and use it in GitHub Desktop.
Lazy way to check if a device supports getUserMedia.
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.
}
@rafaelrinaldi
Copy link
Author

Tested both on iOS (3.3, 4, 5 and 7) and Android version (2.2, 2.3 and 4.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment