M Smith
M Smith

Reputation: 41

Xamarin Forms MediaManager Source property

I am new to Xamarin and Xamarin Forms. I am using the Sample form MediaManager https://github.com/martijn00/XamarinMediaManager. It works with the sample url, but I can't get it to work with a local resource for either iOS or Android.

Upvotes: 3

Views: 1369

Answers (1)

ShokDiesel
ShokDiesel

Reputation: 11

I've only tested this in iOS so far but place the file in your Resources directory.

Then use this code to play the file.

iOS

await CrossMediaManager.Current.Play("myfile.mp3", MediaFileType.Audio, ResourceAvailability.Local);

Android: Place file in Resource/raw folder. Do not add file extension to name.

await CrossMediaManager.Current.Play("android.resource://[PackageName]/raw/myfile", MediaFileType.Audio, ResourceAvailability.Local);

Upvotes: 1

Related Questions