3

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.

3
  • I believe you need to open a stream to the local resource/file and pass that in to MediaManager Commented Mar 29, 2017 at 20:07
  • The source property is a string. Commented Mar 29, 2017 at 20:47
  • I stand corrected - from reviewing their github issues it sounded like that was an option. I'd post an issue on GitHub requesting an example of playing a local file/resource Commented Mar 29, 2017 at 20:52

1 Answer 1

1

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); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.