Patrioticcow
Patrioticcow

Reputation: 27058

how to detect webcam with html5?

i am using this idea, html5 image upload, to capture an image with html5 and a webcam.

the issue i'm having is that the webcam is detected only some times.

if i refresh the page i might not get the ALLOW message and the canvas is blank even though the getUserMedia method is running.

Is there a way to request camera initialisation / detection, even if the browser needs to ask the user to allow the webcam again ?

any ideas on this issue?

thanks

Upvotes: 1

Views: 3347

Answers (1)

markE
markE

Reputation: 105035

Take a look at Addy Osmani's shim for getUserMedia: https://github.com/addyosmani/getUserMedia.js

Source code is available.

He uses a callback that fires when the webcam is successfully ALLOW-ed and is streaming. You might take a look at how he does it.

There's also a callback that fires on error. You could use this callback to attempt a re-do in the event of a timing issue.

He also provides a Flash fallback for the browsers that don't support getUserMedia like IE, Safari, Android and Blackberry.

I read that IE experimentally supports getUserMedia...test with navigator.msGetUserMedia--and check out the API at: http://html5labs.interoperabilitybridges.com/prototypes/media-capture-api-(2nd-updated)/media-capture-api-(2nd-update)/info

Upvotes: 3

Related Questions