Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
CodeToKillBug opened this issue Nov 9, 2021 · 0 comments

Comments

@CodeToKillBug
Copy link

Hi Delpin,
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 snippet :-
`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");
}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant