javascript - Trying to access webcam in html5: Firefox works, Chrome and Opera don't -


i'm trying access webcam through javascript. when use following minimal example below, expect see @ least popup, asking permission access webcam.

this works on firefox, not on chrome or opera (all latest versions).

obviously actual webcam content not yet displayed here, i'm merely initiating getusermedia (or browser specific variant) doesn't work. i'm not getting 'yep' or 'nope' popup (except on firefox).

<!doctype html> <html> <head> <meta charset='utf-8'> <script> function onsuccess(stream) { alert('yes') } function onerror(error) { alert('nope') }  function onload() {   navigator.anygetusermedia = navigator.getusermedia     || navigator.webkitgetusermedia     || navigator.mozgetusermedia     || navigator.msgetusermedia;    navigator.anygetusermedia( {video:true, audio:false}, onsuccess, onerror ); } </script> </head> <body onload='onload()'> </body> </html> 

now strange thing is, when use exact same code on jsfiddle, does work.
live example: http://jsfiddle.net/999anu81/ (if have webcam, should ask permission access it)

what doing wrong?

chrome has restrictions on when getusermedia allowed avoid pages badgering people, iirc. attach button instead of using onload, , should work better.


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -