Using getUserMedia/Stream API with iOS 6

2019-02-22 16:16发布

I am trying to build a web app that will allow users to use the built in camera on an iPad to take a picture or video of themselves and then post it to Facebook. So far I have had no luck when testing getUserMedia() in Safari for iOS 6 or the Chrome app.

This info graphic shows that it is not supported by Safari with iOS 6 but it should work with Chrome, no?

http://caniuse.com/stream

Any help would be much appreciated.

标签: html5 ios6
2条回答
【Aperson】
2楼-- · 2019-02-22 16:46

Currently the only way for mobile Safari to get an image from the camera (or photo roll) is with an input element. It is quite simple:

<input id="image-picker" type="file" accept="image/*" />

Then in js:

$("#image-picker").change( function (event) {
  var files = event.target.files;
  if (files.length>0) {
    // Do something with files[0]
  }
});
查看更多
孤傲高冷的网名
3楼-- · 2019-02-22 16:57

Chrome for iOS uses identical methods/views for displaying and interpreting HTML, with the exception of a few Safari-specific optimizations. If Safari does not support getUserMedia(), then Chrome cannot support it either unless they build their own port of WebKit for iOS, and even then, it might be a stretch. The functionality you are after may be available through some other means, but not using getUserMedia().

查看更多
登录 后发表回答