如何从phonegap中的图库中选择视频?

时间:2015-10-10 08:31:10

标签: android ios cordova video phonegap-plugins

请帮助我任何人如何在cordova中选择Android和iOS中的画廊中的视频 我试过这个click Here来从媒体中选择视频,但它对我不起作用......

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); 
}

我使用相同的代码在我的应用程序中实现,但它不能来....

1 个答案:

答案 0 :(得分:4)

您可以尝试下面的代码段:

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

不是mediaType可以是:

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

参考阅读this