无法从图库/图库 - phonegap / cordova中选择视频 [英] Impossible to pick video from gallery/library - phonegap/cordova
本文介绍了无法从图库/图库 - phonegap / cordova中选择视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是windows phone,cordova / phonegap。
如何从图片库中选择一个视频作为照片?
I am using windows phone, cordova/phonegap. How is possible to pick a video from gallery as it was a picture?
官方插件似乎只适用于图片。
The official plugin seems to work for picture only.
这是代码:
function getVideo() {
var options = { quality: 80 };
options["sourceType"] = 0 | 2;
options["mediaType"] = 1;
navigator.camera.getPicture(onVideoSuccess, onFail, options);
}
var onVideoSuccess = function (fileuri) {
console.log("fileuri " + fileuri);
}
var onFail = function (err) {
console.log("onFail");
}
这种方式我只能选择图片,视频文件?
This way I can select the pictures only, shall I change any parameter to select the video files?
感谢
推荐答案
找到它,但它确实可以通过设置MediaType。
It took some time to find it, but it is indeed possible by setting the MediaType.
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中的PhoneGap选择图片/视频
更多信息: http://docs.phonegap.com/en/1.4.0/phonegap_camera_camera.md.html #Camera
FYI:
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
因此,在您的代码中,您应该更改
So in your code, you should change
options["sourceType"] = 0 | 2;
到:
options["sourceType"] = 1;
只选择影片或:
options["sourceType"] = 0;
只能选择照片或:
options["sourceType"] = 2;
选择两者。
这篇关于无法从图库/图库 - phonegap / cordova中选择视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文