Playing Sound with AVAudioPlayer
Let us know how you feel about this
last updated: 2016-10
This article shows how to use a helper class to control the playback of sound using an AVAudioPlayer.
About the AVAudioPlayer
AVAudioPlayer is used to playback audio data from either memory or a file. Apple recommends using this class to play audio in your app unless you are doing network streaming or require low latency audio I/O.
You can use the
AVAudioPlayer to do the following:
- Play sounds of any duration with optional looping.
- Play multiple sounds at the same time with optional synchronization.
- Control volume, playback rate and stereo positioning for each sounds playing.
- Support features such as fast forward or rewind.
- Obtain playback level metering data.
AVAudioPlayer supports sounds in any audio format provided by iOS, tvOS and OS X such as
Playing Sounds in macOS
Because macOS supports the same Audio Toolbox classes as iOS, please see our iOS Playing Sound with AVAudioPlayer documentation for the full details of playing audio in a Xamarin.Mac app.