2015-10-10 21 views
7

Xin hãy giúp tôi bất kỳ một cách chỉ chọn video từ thư viện trong Android và iOS trong cordova Tôi đang cố gắng click Here này cho chọn video từ phương tiện truyền thông, nhưng nó không làm việc cho tôi ...cách chọn video từ thư viện trong điện thoại?

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

tôi đang sử dụng mã này cùng thực hiện trong ứng dụng của tôi, nhưng nó không thể đi ....

Trả lời

4

Bạn có thể thử đoạn mã dưới đây:

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

không rằng mediaType có thể là:

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 

Để tham khảo, đọc this.

+0

Tôi đã được thử nghiệm như vậy @Rashwan L, nhưng nó sẽ không hoạt động –

+0

Bạn có nhận được bất kỳ thông báo lỗi nào không? –

+0

Đối với Android nó hoạt động tốt nhưng tôi đã thử trong iOS nó không thể làm việc .. @Rashwan L –

Các vấn đề liên quan