Currently I can open image picker using $cordovaImagePicker, but also I want to open video picker for picking the video from gallery/ video gallery.
How can I achieve above task/ thing?
Currently there is no any plugin for picking videos. And html input type=file is open the Mobile Gallery but it’s not provide the file path. Is there another way for this?
1 Like
Yo can use the Camera plugin org.apache.cordova.camera and use this options for select a video from the gallery (Tested in Android):
var options = {
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
mediaType:Camera.MediaType.VIDEO
};
$cordovaCamera.getPicture(options).then( …
1 Like
Hi all i am also getting the same problem as i am trying to access the video path using $cordovaCamera plugin, here is my code:-
$scope.getVideoPath = function(){
var options = {
quality: 50,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
mediaType:Camera.MediaType.VIDEO
};
$cordovaCamera.getPicture(options).then(function(videoURI) {
console.log(“videoURI”,JSON.stringify(videoURI));
console.log(“videoURI”,videoURI.toURI());
}, function(err) {
console.log(“err”,JSON.stringify(err));
});
}
I am getting both the log blank
$scope.getVideoPath = function(){
var options = {
quality: 50,
destinationType: Camera.DestinationType.FILE_URI, // <== try THIS
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
mediaType:Camera.MediaType.VIDEO
};
$cordovaCamera.getPicture(options).then(function(videoURI) {
console.log("videoURI",JSON.stringify(videoURI));
console.log("videoURI",videoURI.toURI());
}, function(err) {
console.log("err",JSON.stringify(err));
});
}
someone suggested it above… is it not working?
@aaronksaunders no its not going to work with
destinationType: Camera.DestinationType.FILE_URI
showing the same blank log.
log videoURI, “”
this we just release a production app for a client using that in our code… would need to see more of your application to understand why you are running into issues. Sorry couldn’t help more
@aaronksaunders it true in case of Image only that is:-
quality: 50, destinationType: Camera.DestinationType.FILE_URI, sourceType: Camera.PictureSourceType.PHOTOLIBRARY, mediaType:Camera.MediaType.SAVEDPHOTOALBUM OR mediaType:Camera.MediaType.PHOTOLIBRARY
<== seee this
Log in case of Image :- videoURI, “content://media/external/images/media/31249”
Log in case of Video :- videoURI, “”
@PradeepGill are you able to solve this ? facing the same issue
RahulSalvikar’s idea works for me. But I think we can’t use cordova plugins as Camera.
. We have to use (<any>window).Camera.
For anyone interested in future here’s how I did it. I also used ionic native camera plugin.
import { Camera } from '@ionic-native/camera';
constructor(public navCtrl: NavController,
private camera: Camera
) {
}
loadGallery() { // select video from gallery
var options = {
quality: 50,
destinationType: (<any>window).Camera.DestinationType.FILE_URI,
sourceType: (<any>window).Camera.PictureSourceType.PHOTOLIBRARY,
mediaType: (<any>window).Camera.MediaType.VIDEO
}
this.camera.getPicture(options).then( (data) => {
console.log(data);
}, (err) => {
console.log(err);
});
}