Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to select the video from gallery in phonegap?

Please help me any one how to select only the video from the gallery in android and iOS in cordova I am tried this click Here for select the video from media but it not working for me...

var pictureSource; 
var destinationType; 
var mediaType;

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

function onDeviceReady() {
 pictureSource = navigator.camera.PictureSourceType;
 destinationType = navigator.camera.DestinationType;
 mediaType = navigator.camera.MediaType;
}

navigator.camera.getPicture(onPhotoURISuccess, onFail, {
  destinationType: destinationType.FILE_URI,
  mediaType: mediaType.VIDEO,
  sourceType: source
});

function onPhotoURISuccess(imageURI) {
  console.log(imageURI);
}

function onFail(message) {
  console.log(message); 
}

i am used this same code to implement in my app but it can't come....

like image 561
Hari Narayanan Avatar asked Oct 10 '15 08:10

Hari Narayanan


1 Answers

You can try the snippet below:

navigator.camera.getPicture(onSuccess, onFail, { quality: 100,
    destinationType: Camera.DestinationType.FILE_URI,
    sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
    mediaType: Camera.MediaType.VIDEO
  });

Not that the mediaType can be:

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            // allow selection from all media types

For reference read this.

like image 72
Rashwan L Avatar answered Sep 29 '22 07:09

Rashwan L