Search code examples
javascriptcordovajquery-pluginscameracordova-plugins

Use Camera in Cordova?


I am building a cordova app. it supports two platform (ios and Android). In this i have to show a camera in given frame of the app. Below the frame of camera, there will be a button named "Click". When i click this button, the currently showing things in camera should be captured and saved to gallery. Also there should be a slide bar on the left of camera. using this slider, one can zoom in or zoom out the camera.

Currently i have tried "org.apache.cordova.camera" http://plugins.cordova.io/#/package/org.apache.cordova.camera. But, i don't know how to present camera in a given frame. It is invoking the default camera app and the camera is opening in full screen. Please suggest me some another plugin or any Method.

Thanks.


Solution

  • I'm not sure about displaying in a frame, but typically when you use the camera plugin it fires into the native camera effectively leaving you're app until the user either exits or takes a picture. It is at that stage you can handle the response data.

    So for example, you would have a button, link or whatever when clicked you call something like the code below. You can then on the onSuccess callback load the image into a dynamically created canvas or something like that.

    navigator.camera.getPicture(onSuccess, onFail, { 
     quality            : 40,
     destinationType    : Camera.DestinationType.DATA_URL,
     encodingType       : Camera.EncodingType.JPEG,
     targetWidth        : 1600,
     targetHeight       : 1200,
     sourceType         : Camera.PictureSourceType.CAMERA,
     correctOrientation : true
    });