question

WeiWen-3421 avatar image
0 Votes"
WeiWen-3421 asked KyleWang-MSFT answered

How to set FilePickerType if I want to pick audio files

For picking videos, photos and documents, there are readily available examples on the web to use. However, I didn't find any example on setting up the file types for audios. An example I found for picking document is like below. Is there something similar for audio files?


  var customFileType = new FilePickerFileType(new Dictionary<Xamarin.Essentials.DevicePlatform, IEnumerable<string>>
             {
               { Xamarin.Essentials.DevicePlatform.iOS, new[] {"com.adobe.pdf", "com.microsoft.word.doc", "org.openxmlformats.wordprocessingml.document" } },
               { Xamarin.Essentials.DevicePlatform.Android, new[] {"application/pdf", "application/doc", "application/document" } }
             });


dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

KyleWang-MSFT avatar image
0 Votes"
KyleWang-MSFT answered

Hi WeiWen-3421,

Welcome to our Microsoft Q&A platform!

According to the documentation: PickOptions.FileTypes Property, we can know that

every platform has its own way to specify the file types.
On Android you can specify one or more MIME types, e.g. "image/png"; also wild card characters can be used, e.g. "image/*".
On iOS you can specify UTType constants, e.g. UTType.Image.
On UWP, specify a list of extensions, like this: ".jpg", ".png

By goggling key word "mime type list", you will get the MIME types you can use for audio.
As to iOS, you can refer to the documentation: System Declared Uniform Type Identifiers.

Here is a simple example.

  new FilePickerFileType(new Dictionary<DevicePlatform, IEnumerable<string>>
  {
      { DevicePlatform.iOS, new[] { "public.mp3" } },
      { DevicePlatform.Android, new[] { "audio/mpeg" } }
  });

Regards,
Kyle


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.