Skip to content Skip to sidebar Skip to footer

Pick An Image / Video Using Phonegap In Android

How can I pick an image / video ( or take a photo / video ) using PhoneGap in Android ? I have a web form needs to pick image / video contents and submit the form to upload the con

Solution 1:

Yes you can upload image to server with phonegap

Here is the code to pick image or video

document.addEventListener("deviceready", onDeviceReady, false);

functiononDeviceReady() {
    pictureSource = navigator.camera.PictureSourceType;
    destinationType = navigator.camera.DestinationType;
}

    functioncapturePhoto() {
    navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50, 
    destinationType: destinationType.FILE_URI });
}

functiongetPhoto(source) {
    navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50, 
    destinationType: destinationType.FILE_URI,
    sourceType: source });
}

functiononPhotoURISuccess(imageURI) {
    // do whatever with imageURI
}

in html you have to write

<buttonclass="btn large"onclick="capturePhoto();">Capture Photo</button><buttonclass="btn large"onclick="getPhoto(pictureSource.PHOTOLIBRARY);">From
        Photo Library</button>

for video

Camera.MediaType = { 
    PICTURE: 0,             // allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType
    VIDEO: 1,               // allow selection of video only, WILL ALWAYS RETURN FILE_URI
    ALLMEDIA : 2     }

even you can go through this

http://docs.phonegap.com/en/1.4.0/phonegap_camera_camera.md.html#Camera

Post a Comment for "Pick An Image / Video Using Phonegap In Android"