xamarin / Essentials

Xamarin.Essentials is no longer supported. Migrate your apps to .NET MAUI, which includes Maui.Essentials.
https://aka.ms/xamarin-upgrade
Other
1.52k stars 505 forks source link

MediaPicker.PickVideoAsync() name of video #2014

Open rocny15 opened 2 years ago

rocny15 commented 2 years ago

Description

On iOS when a video is uploaded from the device to the application the file name is modified.

Steps to Reproduce

  1. Load the video using MediaPicker.PickVideoAsync() on the iOS device.

Expected Behavior

Actual Behavior

Basic Information

Screenshots

Reproduction Link

jfversluis commented 2 years ago

I'm going to need a bit more information here. What is the code you're using? Do you have a reproduction project that you can show for this? What do you mean by "uploaded from the device to the application"?

rocny15 commented 2 years ago

Code fragment:

private async Task pickVideo() { try { var file = await MediaPicker.PickVideoAsync();

            var filePath = await loadFileResultAsync(file);

            if (filePath == null)
                return;

            _filesAction(new List<IFileWrapper> { new

FileInfoFileWrapper(new FileInfo(filePath)) });

            BindModalItem();

            _onDialogClosed(null);
        }
        catch (Exception e)
        {
            UserDialogs.Instance.Alert("Unable to select video at this

time"); ApplicationViewModel.Current.SendUserEvent(e); } }

problem scenario

I have my app open on my iPhone or iPad and I want to upload a video to my app and then save it to a database.

The video I load is named "video_2022.mp4". When I add the video to the ListView and save to my database the name is trim.D823445678-DF01-345.mov I have noticed that this happens in the process of converting mp4 to mov, but I need to find to keep the name of the file loaded.

El jue, 25 ago 2022 a la(s) 14:32, Gerald Versluis @.***) escribió:

I'm going to need a bit more information here. What is the code you're using? Do you have a reproduction project that you can show for this? What do you mean by "uploaded from the device to the application"?

— Reply to this email directly, view it on GitHub https://github.com/xamarin/Essentials/issues/2014#issuecomment-1227624055, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARKT3GZAVNDDAR4UPSEE5GLV2635BANCNFSM5XEBMSDQ . You are receiving this because you authored the thread.Message ID: @.***>

jfversluis commented 2 years ago

What does loadFileResultAsync do? Is the filename correct right after await MediaPicker.PickVideoAsync();?

Based of this snippet it's still hard to say if this is anything caused by Essentials

tahahalwanii commented 6 months ago

@jfversluis Bumping this issue because I'm currently facing this.

To give a quick summary about this issue, this is basically happening on iOS devices when using await MediaPicker.PickVideoAsync();.

Based on what I've seen, the selected video is copied into a temp folder, with a new temp file name. Example of the FullPath property of the FileResult after picking a video: "/private/var/mobile/Containers/Data/PluginKitPlugin/9161A3A2-2BEE-4DB4-A47B-1EF426370247/tmp/trim.3C339653-B9EB-4022-B5A1-96F42656C488.MOV".

The new copied file is prefixed with "trim." and a new Guid as its file name. The original file name is lost.

An indication on what might be happening is that when picking a video, the OS will start to compress the video, possibly copying it along the way, and then returning this new compressed file instead of the original.