10


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

Sam Hanley
  • 4,707
  • 7
  • 35
  • 63
Luis Evrythng
  • 1,085
  • 10
  • 15
  • Since that test you have above doesn't work, first I would append the element in the body, and set a type to accept media (i.e. the attributes `type="file"`, `accept="image/*"`, `accept="video/*"`, etc), if that fails then I'd probably go with just going though the User Agent string and testing if the browser is a version that has support. Also, you don't have quotes around your `input` or `capture` so it will error out because they will be undefined variables. –  Jun 12 '13 at 17:09
  • The question has been answered here : http://stackoverflow.com/questions/12199736/detect-html5-media-capture-api-support – mbejda Apr 27 '15 at 02:26

2 Answers2

1

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...

Kaiido
  • 123,334
  • 13
  • 219
  • 285
-1

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);
}
RickyAYoder
  • 963
  • 1
  • 13
  • 29
  • 3
    Can you share where it says that HTML Media Capture is deprecated and obsolete? – mscdex Sep 02 '15 at 16:24
  • 2
    I would add that it's improbable that it's outdated, nor deprecated nor obsolete since it never gone out of the drafts. the stream API and the HTML MEDIA Capture are different, The former provides a stream, when the later provides a File. – Kaiido Sep 12 '15 at 08:38