An audio player that provides playback of audio data from a file or memory.
- iOS 2.2+
- macOS 10.7+
- tvOS 9.0+
- watchOS 3.0+
Use this class for audio playback unless you are playing audio captured from a network stream or require very low I/O latency.
Using an audio player you can:
Play sounds of any duration
Play sounds from files or memory buffers
Play multiple sounds simultaneously, one sound per audio player, with precise synchronization
Control relative playback level, stereo positioning, and playback rate for each sound you are playing
Seek to a particular point in a sound file, which supports such application features as fast forward and rewind
Obtain data you can use for playback-level metering
AVAudio class lets you play sound in any audio format available in iOS and macOS. You implement a delegate to handle interruptions (such as an incoming phone call on iOS) and to update the user interface when a sound has finished playing. The delegate methods are described in
To play, pause, or stop an audio player, call one of its playback control methods, described in Configuring and Controlling Playback.
This class uses the Objective-C declared properties feature for managing information about a sound, such as the playback point within the sound’s timeline, and for accessing playback options, such as volume and looping.