Cordova Camera Plugin returns green pictures Windo

2019-04-14 20:17发布

问题:

Very strange behaviour: after takinf a 2nd or third picture using cordova camera plugin returned picture is green and about 200kb while normally about 2 mb. When taking more 'green' pictures application crashes and default camera screen becomes green untill phone is restarted.

Tryed different parameters like getting url instead of base64, different picture sizes - no luck.

This is reproduced on Nokia Lumia 520, but Microsoft Lumia 535 allowes to take about 6 pictures. While android works fine.

Code looks like:

navigator.camera.getPicture(onSuccess, onFail, {
    quality: 50,
    destinationType: Camera.DestinationType.DATA_URL,
    encodingType: Camera.EncodingType.JPEG,
    sourceType : Camera.PictureSourceType.CAMERA
});

Tryed to use capture plugin result is the same.

回答1:

You may try this:

camera: {
    pictureSource: "UNDEFINED",
    destinationType: "UNDEFINED",
    cameraInitialize: function () {
        pictureSource = navigator.camera.PictureSourceType;
        destinationType = navigator.camera.DestinationType;
        cameraOptions = { quality: 50, allowEdit: true, destinationType: destinationType.DATA_URL, correctOrientation: true }
        galleryOptions = { quality: 50, destinationType: destinationType.DATA_URL, sourceType: pictureSource.PHOTOLIBRARY }
    },
    getPicture: function (cameraSuccess, cameraError, cameraOptions) {
        navigator.camera.getPicture(cameraSuccess, cameraError, cameraOptions);
    }
},


回答2:

For me the only solution so far (per microsoft support) is to hard reset your phone. I have an ancient Lumia running windows phone 8.1 and it is having the same issue in my app.

I actually think that the device is overheating.

Also things you should do to help avoid camera issues in your WP app:

  • Assuming you use cordova, check if the video object has the maximum z-index and check if it isn't stacking under your application.
  • If you also use angular, some button types fire ng-click twice on IE and so the camera opens twice.
  • Implement cordova-camera-plugin 2.0.0 which fixes things like double-tapping in the camera and making it crash

I hope this helps you in your painful quest.