Polyfill file input with accept capture (using getUserMedia to capture?)

放肆的年华 提交于 2019-12-05 08:19:51

I've since found getUserMedia.js, which works in Firefox. It falls back to Flash, which is nice, I'll have to see if I am able to tweak it to fall back to input type="file" in mobile browsers.

On desktop, to access the webcam:

  • use the (now deprecated) navigator.getUserMedia OR
  • use the new promise based navigator.mediaDevices.getUserMedia

Once access is granted, to record the webcam:

  • use the Media Recorder API, it's now supported in Chrome/Firefox (demo & code) OR
  • use WebRTC and stream the video to a media server where you can record it

PS: on mobile the HTML Media Capture spec has evolved, accept="image/*;capture=camera" never made it to the W3C Candidate Recommendation. Use just accept="image/*" instead and separately add capture="capture"(Boolean) only if you want to force capture from the camera. See Correct Syntax for HTML Media Capture for more details.

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