gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 03:32:11 25 4
gpt4 key购买 nike

请帮助我如何在 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);
}

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

最佳答案

您可以尝试以下代码段:

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 - 如何从 phonegap 中的图库中选择视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33051947/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com