I\'m creating an app for Android, iOS and Windows Phone using Xamarin.forms. My question is how to play a mp3 or wav with Xamarin Forms?
My business logic is handled by
You might give Xam.Plugin.SimpleAudioPlayer a try, since Xamarin.Forms doesn't have a sound API.
In short, add the NuGet package to each platform-specific project you wish to support. Copy the audio files to the Assets folder for Windows UWP and Android and set the build actions as Content
and Android Asset
respectively. For iOS copy the audio files to the Resources folder and set the build action to BundleResource
, then play the files like so:
var player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
player.Load("intro_sound.mp3");
player.Play();