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....


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.

链接地址: http://www.djcxy.com/p/88214.html

上一篇: 为什么removeServerHeader在Azure Web App中工作?

下一篇: 如何从手机中的图库中选择视频?