HTML5 Access Camera on Android device fails -


i trying print camera input canvas element in html5. on desktop works fine, building android devices cordova, cannot access camera , don't know wrong. tried crosswalk, there no error, camera isn't shown either. want cordova, becuase have use cordova plugins.

here code:

   navigator.getusermedia = (navigator.getusermedia || navigator.webkitgetusermedia || navigator.mozgetusermedia || navigator.msgetusermedia);     navigator.getusermedia(options, onsuccess, onfail);  var options = {      audio: false,      video: {       mandatory: {        maxwidth: window.innerwidth,        maxheight: window.innerheight       },       optional: [{ facingmode: "user" }]  } }  var onfail = function(e) {   alert('failed camera'); };  var onsuccess = function(stream) {     var video = document.getelementbyid('my-webcam');     if(navigator.mozgetusermedia) {         video.mozsrcobject = stream;         console.log("videowidth" + video.width);     } else {         var url = window.url || window.webkiturl;         video.src = url.createobjecturl(stream);     }      // wait 1000 ms before starting loop otherwise videosize aren´t set, canvas can´t values video     settimeout(function(){         setinterval(updatecanvas,30); //manipulating canvas here         // make sure canvas same size video         var video = document.getelementbyid('my-webcam'); //invisible         var canvas = document.getelementbyid('my-canvas'); //where camera input should shown         canvas.width = video.videowidth;         canvas.height = video.videoheight; //- $('#mainpage_buttonphoto').height();     },1000); }; 

but if build this, onfail alert "failed camera".

i figured out "errorpermissiondeniederror". build xdk. android.json, or app manifest building android still not working.

{ "prepare_queue": {     "installed": [],     "uninstalled": [] }, "config_munge": {     "files": {} }, "installed_plugins": {}, "dependent_plugins": {}, "permissions": {   "audio-capture": {     "description": "required capture audio using getusermedia()",       access: "readwrite"   },   "video-capture": {     "description": "required capture video using getusermedia()",       access: "readwrite"   } } } 


Comments

Popular posts from this blog

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

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

html - jQuery UI Sortable - Remove placeholder after item is dropped -