Detect browser support for HTML Media Capture
Asked Answered
K

2

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

Kelsi answered 12/6, 2013 at 16:23 Comment(2)
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.Directional
The question has been answered here : #12200236Anthropometry
V
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...

Voluminous answered 13/9, 2015 at 3:54 Comment(0)
G
-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);
}
Graphic answered 13/7, 2015 at 5:21 Comment(2)
Can you share where it says that HTML Media Capture is deprecated and obsolete?Splashdown
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.Voluminous

© 2022 - 2024 — McMap. All rights reserved.