Przeglądaj źródła

avalonia: Fixed android video selector

Kenric Nugteren 1 tydzień temu
rodzic
commit
aa0cc69148

+ 5 - 3
InABox.Avalonia.Platform.Android/ImageTools.Android.cs

@@ -81,7 +81,7 @@ namespace InABox.Avalonia.Platform.Android
         
         public async Task<ImageFile?> PickVideoAsync(TopLevel window)
         {
-            var fileResult = await MediaPicker.PickPhotoAsync();
+            var fileResult = await MediaPicker.PickVideoAsync();
             if (fileResult == null)
                 return null;
             await using var stream = await fileResult.OpenReadAsync();
@@ -90,11 +90,13 @@ namespace InABox.Avalonia.Platform.Android
         
         public async Task<ImageFile?> CaptureVideoAsync(TopLevel window)
         {
-            var fileResult = await MediaPicker.CapturePhotoAsync();
+            var fileResult = await MediaPicker.CaptureVideoAsync();
             if (fileResult == null)
                 return null;
             await using var stream = await fileResult.OpenReadAsync();
-            return await ProcessFile(stream, null, null);
+            using var memStream = new MemoryStream();
+            stream.CopyTo(memStream);
+            return new ImageFile(fileResult.FileName, memStream.ToArray());
         }
 
         private async Task<ImageFile> ProcessFile(Stream stream, int? compression, Size? constraints)