HTML Media Capture API vs. getUserMedia()

后端 未结 2 1991
感情败类
感情败类 2021-01-31 11:41

currently, I\'m trying to do some really simple thing (well, actually I thought it is simple...): I want to take a photo from the web-cam in a web-application.

相关标签:
2条回答
  • 2021-01-31 11:54

    Mobile browsers

    Use HTML Media Capture to capture an image directly from the camera:

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

    Android (3.0+) will jump straight to the camera. Here's how it will look after some CSS styling:

    iOS (6-10) will still give you the option to select an existing photo since it doesn't support capture. See Correct Syntax for HTML Media Capture for details.

    Desktop browsers:

    1) Access the webcam: use MediaStream API's getUserMedia:

    navigator.getUserMedia or the newer promise based navigator.mediaDevices.getUserMedia

    2) Use the canvas to take a snapshot

    David Walsh's example covers both steps on desktop.

    0 讨论(0)
  • 2021-01-31 11:58

    here is example http://html5.by/blog/demo/image-capture-getusermedia/ and here is article that can help you http://html5.by/blog/html5-image-capture-getusermedia-stream-api-mirror/ sorry it is in Russian, but example is working and you can check the code + google translate :)

    hope it will help

    0 讨论(0)
提交回复
热议问题