2

I'm wondering why camera/select-file behavior differs not only between browsers (Chrome, Safari), but also between the same browser on different platforms (Android Chrome vs iPhone Chrome)?

Modernizr.getusermedia returns true for Chrome on Android, but false for Chrome on iPhone.

Problem: on iPhone Modernizr.getusermedia === false, but on <input type="file" /> menu Chrome/Safari propose me to make a photo/video.

Question: is there any way to take under JavaScript control that behaviour?

VB_
  • 45,112
  • 42
  • 145
  • 293
  • 3
    Just as an aside - chrome on android is in _no_ way the same browser as chrome on ios. at all. Apple does not allow for third party web engines. As a result, chrome on ios is just a wrapper around safari's web view. – Patrick Oct 27 '15 at 04:52
  • @Patrick thanks, good point – VB_ Oct 27 '15 at 07:28

2 Answers2

7

Tried adding capture attribute to input element ?

<input type="file" accept="image/*;capture=camera">

See Polyfill file input with accept capture (using getUserMedia to capture?) , Capturing Audio & Video in HTML5

Community
  • 1
  • 1
guest271314
  • 1
  • 15
  • 104
  • 177
  • nice suggestion, will try it today! – VB_ Oct 27 '15 at 07:28
  • 1
    `accept="image/*;capture=camera"` was replaced with `accept="image/*" capture` in the [W3C Recommendation](https://www.w3.org/TR/2013/CR-html-media-capture-20130509/). Use `capture="capture"` only if you want to capture directly from the camera. See [Correct Syntax for HTML Media Capture](https://addpipe.com/blog/correct-syntax-html-media-capture/) for more details. – octavn Nov 10 '16 at 12:29
  • @OctavianNaicu See also https://www.w3.org/2009/dap/wiki/ImplementationStatus , http://w3c.github.io/test-results/html-media-capture/all.html – guest271314 Nov 10 '16 at 16:44
1

I'm wondering why camera/select-file behavior differs between the same browser on different platforms (Android Chrome vs iPhone Chrome)?

Chrome on iOS is actually just a wrapper around Webkit, Safari's rendering engine.

on iPhone Modernizr.getusermedia === false, but on <input type="file" /> menu Chrome/Safari propose me to make a photo/video.

Those are two different APIs. getUserMedia is a complex JavaScript API not implemented by Safari, while <input type="file" accept="image/*"/> is a very simple HTML5 API.

Community
  • 1
  • 1
Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404