HTML5 Safari iOS access only camera not photo library

♀尐吖头ヾ 提交于 2020-01-13 04:28:08

问题


<input type="file" capture="camera" accept="image/*"> allows a mobile browser to take a picture. On Android native browser and chrome, clicking the input button launches the camera instantly. On iOS Safari, the button launches an alert asking to "Take Photo" or choose from "Photo Library". How can I launch the native camera immediately?


回答1:


It has to do with who is supporting WebRTC. Currently there is no Safari support, partial support from Chrome on Android, experimental support from Firefox for Android. On Android, the default behavior is to use the front facing camera. Future work will allow us to choose the camera from javascript, but this feature is only experimental in FireFox.




回答2:


It's not possible on iOS at this time.

iOS6 through 10 do not support the capture attribute which is meant to force the user agent to use the camera, not the "Photo Library".

The capture attribute is part of HTML Media Capture.

PS: You could improve your code by replacing capture="camera" with just capture. In 2012 the capture attribute was changed from 4 strings to boolean in the HTML Media Capture spec.



来源:https://stackoverflow.com/questions/26518344/html5-safari-ios-access-only-camera-not-photo-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!