【问题标题】:how to select the video from gallery in phonegap?如何从 phonegap 的图库中选择视频?
【发布时间】:2015-10-10 08:31:09
【问题描述】:

请帮助我如何在科尔多瓦的 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); 
}

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

【问题讨论】:

    标签: android ios cordova video phonegap-plugins


    【解决方案1】:

    你可以试试下面的sn-p:

    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

    【讨论】:

    • 对于 Android 来说它工作正常,但我在 iOS 中试过它不能工作.. @Rashwan L
    • 奇怪..你试过this吗?
    • 好的,试试吧,我会在后面更新我的答案,但我的答案中的当前代码应该可以工作。祝你好运@HariNarayanan
    • 尝试 ios github.com/apache/cordova-plugin-file 和 resolveLocalFileSystemURL 方法以获得视频文件的正确路径
    • 你找到解决方案了吗@HariNarayanan?上面的评论对你有帮助吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-04-02
    • 1970-01-01
    • 2013-12-29
    • 2017-09-21
    • 1970-01-01
    • 2017-01-24
    • 2019-01-04
    相关资源
    最近更新 更多