简体   繁体   中英

PhoneGap/Cordova CanvasCamera Plugin not working

I am running the app on ios 9.2 via PhoneGap Desktop.

I have just started out using PhoneGap and I am trying to build a simple app that allows you to take a picture and show it back to you. I have been able to do this using the cordova camera plugin that launches the camera app on the device. however I would like to implement the app that launches a full screen camera as soon as the device is ready, just like snapchat.

I have been trying to do this using the CanvasCamera Plugin by Donald Pae https://github.com/donaldp24/CanvasCameraPlugin

But still I have had NO success in getting the camera preview.

I have installed the plugin via npm using gitbash

I have added the plugin to the config.xml file

    <gap:plugin name="com.keith.cordova.plugin.canvascamera" version="1.0.1" />

This is the code that I am using to try and get a camera preview

HTML

    <canvas id="camera" width="352" height="288" style="border:2px solid black"></canvas>

index.js Inside the bind events function

        document.addEventListener("deviceready", function() {
          canvasMain = document.getElementById("camera");
          window.plugin.CanvasCamera.initialize(canvasMain);
          // define options
          var opt = {
              quality: 75,
              destinationType: CanvasCamera.DestinationType.DATA_URL,
              encodingType: CanvasCamera.EncodingType.JPEG,
              saveToPhotoAlbum:true,
              correctOrientation:true,
              width:640,
              height:480
          };
          window.plugin.CanvasCamera.start(opt);
      });

I really appreciate your help.

thanks

Try to run the app through simulator via connecting your phone to your PC using USB. Note that you need to create iOS platform in order to run it in your phone. I hope it will work with you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM