How can I detect browser support for HTML Media Capture* ?
The traditional way of testing if an attribute is supported doesn't seem to work on some devices (tested on iPad and Google Nexus):
var elm = document.createElement(input);
if (capture in elm) {
return true;
}
There's a test for Modernizr but it doesn't seem to be reliable (it uses the same principle):
https://github.com/Modernizr/Modernizr/pull/909
__
(*) More info on HTML Media Capture:
http://www.w3.org/TR/html-media-capture/
http://www.html5rocks.com/en/tutorials/getusermedia/intro/#toc-round1
I hope I'm wrong, but it seems we won't be able to make this detection...
The last paper about this HTML MEDIA Capture API (which is different than the Streaming/GetUserMedia API), as been posted last year (2014), and never gone out of the drafts...
This comment from 2012 on a request to implement this feature in Firefox clearly states that :
[T]here is no real need to implement that. It should come for free with Android Intent system. We should just call in intent for ACTION_IMAGE_CAPTURE/ACTION_VIDEO_CAPTURE.
Which means that this feature comes from the OS directly, and that we as developers won't have any way to know if this will be available or not...
So the only way to detect this feature seems to be a UserAgent match against known supporting devices...
This form of media capture in browsers is outdated, deprecated, and obsolete. The new standard, getUserMedia, can be detected like so:
function hasGetUserMedia() {
return !!(navigator.getUserMedia || navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia || navigator.msGetUserMedia);
}