Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

CrossMedia.Current.TakeVideoAsync saves the video in the designated folder but with zero bytes.

$
0
0

Summary: When I capture a video, I get two files created. One in DCIM/100Media and one in a project file. The latter one has no bytes.

I am able to use the Media.Plugin (V 2.6.2) to capture photos successfully. I am doing something similar for videos but it is not working right. I am following the instructions at https://github.com/jamesmontemagno/MediaPlugin and using the
file_paths.xml
to indicate what folder to save the images in. It looks like this:
`
<?xml version="1.0" encoding="utf-8"?>

 <paths xmlns:android="http://schemas.android.com/apk/res/android">

   <external-path name="my_images" path="Android/data/com.<company>.<appname>/files/Pictures" />

   <external-path name="my_movies" path="Android/data/com.<company>.<appname>/files/Movies" />
 </paths>

`

My code looks like this:

`
takeVideo.Clicked += async (sender, args) =>

 {

     await CrossMedia.Current.Initialize();

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

                var file = await CrossMedia.Current.TakeVideoAsync(new Plugin.Media.Abstractions.StoreVideoOptions
                {
                    Directory = "Sample",
                    Name = "test.mp4"
                });

                if (file == null)
                    return;

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

                image.Source = ImageSource.FromStream(() =>
                {
                    var stream = file.GetStream();
                    file.Dispose();
                    return stream;
                });
}

`
The DisplayAlert shows the expected file.Path. When I navigate to that location using a File Manager, the file is there with zero bytes. Meanwhile, another copy of the video that I have taken is found in DCIM/100MEDIA with a generic name (VIDEO0015.mp4) and I can watch it.

1) What should I do to get the full video in the desired folder?
2) How can I avoid saving something to DCIM/100MEDIA?

Thanks!


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>