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.
- I believe you need to open a stream to the local resource/file and pass that in to MediaManagerJason– Jason2017-03-29 20:07:13 +00:00Commented Mar 29, 2017 at 20:07
- The source property is a string.M Smith– M Smith2017-03-29 20:47:32 +00:00Commented 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/resourceJason– Jason2017-03-29 20:52:46 +00:00Commented Mar 29, 2017 at 20:52
Add a comment |
1 Answer
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);