Cannot access camera in gonative.io app

2019-08-23 20:01发布

问题:

I have a webpage and show the camera stream to a user so that the user can take a snapshot later. I am using navigator.mediaDevices.getUserMedia:

<video autoplay id="mycamtestvideo"></video>
<script>
  navigator.mediaDevices.getUserMedia({video: true})
  .then(function(stream){
      video.src = window.URL.createObjectURL(stream);
      localMediaStream = stream;
 })
 .catch(function(err){
    console.log("error: "+err);
 });
</script>

I can open the webpage in a browser on my PC and my android phone and see the camera stream just fine. However, when I create an android app from my webpage using gonative.io, the video is not rendered but just a gray box with a circle and a play button in it are shown at the location of the video. How should I access the camera in a converted gonative.io app?

Thanks.

回答1:

There is the app manifest where you need to specify which permissions your app needs. If you click on the camera button and the camera won't open (not sure if this is your question) it means your app doesn't have permission to the camera app.

Read about App Manifest here.

If you have everything in order (i.e. Camera permissions are in place), you will have to visit your private management URL and change the Webview Settings. Enable where it says "Android requires permission to allow downloading to device's downloads directory."