Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

TakeVideoAsync doesn't save recorded video to the gallery with SaveToAlbum = true #937

Open
CodeToKillBug opened this issue Nov 11, 2021 · 2 comments

Comments

@CodeToKillBug
Copy link

I've tried recording video on Xamarin Forms Application and found the problem when I try to picking up the video I've recorded. The video that is just recorded doesn't show in video picker As it showing recorded videos path :- App Memory (/storage/emulated/0/Android/data/com.companyname.AppName/files/Movies/) but While we try to Pick the same Video, we are unable to find the actual video which is not getting saved in device. But if I switch to taking picture and pick it the picture to upload in firebase storage up there's no problem.

#Code :-

async void OnCaremaIconClicked(object sender, EventArgs e)
{
await CrossMedia.Current.Initialize();

if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakeVideoSupported)
{
    DisplayAlert("No Camera", ":( No camera avaialble.", "OK");
    return;
}

var file = await Plugin.Media.CrossMedia.Current.TakeVideoAsync(new Plugin.Media.Abstractions.StoreVideoOptions
{
    Directory = "DefaultVideos",
    Name = "video.mp4",
    SaveToAlbum = true
});
//await Task.Delay(6000);
if (file == null)
    return;

await DisplayAlert("Video Recorded", "Location: " + file.AlbumPath, "OK");
file.Dispose();
//=====================================Picture==================================

//if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
//{
//    DisplayAlert("No Camera", ":( No camera available.", "OK");
//    return;
//}

//var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
//{
//    Directory = "Sample",
//    Name = "test.jpg",
//    SaveToAlbum = true
//});

//if (file == null)
//    return;

//await DisplayAlert("File Location", file.AlbumPath, "OK");

}

async void OnVideoPickerIconClicked(object sender, EventArgs e)
{
await CrossMedia.Current.Initialize();

if (!CrossMedia.Current.IsPickVideoSupported)
{
    DisplayAlert("Videos Not Supported", ":( Permission not granted to videos.", "OK");
    return;
}
var file = await Plugin.Media.CrossMedia.Current.PickVideoAsync();

if (file == null)
    return;

await DisplayAlert("Video Selected", "Location: " + file.AlbumPath, "OK");
//file.Dispose();

//================================PICTURE==============================

//if (!CrossMedia.Current.IsPickPhotoSupported)
//{
//    DisplayAlert("Photos Not Supported", ":( Permission not granted to photos.", "OK");
//    return;
//}
//var file = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
//{
//    PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium,

//});


//if (file == null)
//    return;
//await DisplayAlert("Video Selected", "Location: " + file.AlbumPath, "OK");

}

@boris-df
Copy link

On Android this library doesn't seem to store the video in the public gallery - it works on iOS and it works with Photos on Android but with Video in Android.
Don't know why yet :'(

@boris-df
Copy link

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants