<!--
{
  "availability" : [
    "iOS: 2.2.0 -",
    "iPadOS: 2.2.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFAudio",
  "identifier" : "/documentation/AVFAudio/AVAudioPlayer",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AVFAudio"
    ],
    "preciseIdentifier" : "c:objc(cs)AVAudioPlayer"
  },
  "title" : "AVAudioPlayer"
}
-->

# AVAudioPlayer

An object that plays audio data from a file or buffer.

```
class AVAudioPlayer
```

## Overview

Use an audio player to:

- Play audio of any duration from a file or buffer
- Control the volume, panning, rate, and looping behavior of the played audio
- Access playback-level metering data
- Play multiple sounds simultaneously by synchronizing the playback of multiple players

For more information about preparing your app to play audio, see <doc://com.apple.documentation/documentation/AVFoundation/configuring-your-app-for-media-playback>.

> Important:
> For more advanced playback capabilities, like playing streaming or positional audio, use ``doc://com.apple.avfaudio/documentation/AVFAudio/AVAudioEngine`` instead.

## Topics

### Creating an audio player

[`init(contentsOf:)`](/documentation/AVFAudio/AVAudioPlayer/init(contentsOf:))

Creates a player to play audio from a file.

[`init(contentsOf:fileTypeHint:)`](/documentation/AVFAudio/AVAudioPlayer/init(contentsOf:fileTypeHint:))

Creates a player to play audio from a file of a particular type.

[`init(data:)`](/documentation/AVFAudio/AVAudioPlayer/init(data:))

Creates a player to play in-memory audio data.

[`init(data:fileTypeHint:)`](/documentation/AVFAudio/AVAudioPlayer/init(data:fileTypeHint:))

Creates a player to play in-memory audio data of a particular type.

### Controlling playback

[`prepareToPlay()`](/documentation/AVFAudio/AVAudioPlayer/prepareToPlay())

Prepares the player for audio playback.

[`play()`](/documentation/AVFAudio/AVAudioPlayer/play())

Plays audio asynchronously.

[`play(atTime:)`](/documentation/AVFAudio/AVAudioPlayer/play(atTime:))

Plays audio asynchronously, starting at a specified point in the audio output device’s timeline.

[`pause()`](/documentation/AVFAudio/AVAudioPlayer/pause())

Pauses audio playback.

[`stop()`](/documentation/AVFAudio/AVAudioPlayer/stop())

Stops playback and undoes the setup the system requires for playback.

[`isPlaying`](/documentation/AVFAudio/AVAudioPlayer/isPlaying)

A Boolean value that indicates whether the player is currently playing audio.

### Configuring playback settings

[`volume`](/documentation/AVFAudio/AVAudioPlayer/volume)

The audio player’s volume relative to other audio output.

[`setVolume(_:fadeDuration:)`](/documentation/AVFAudio/AVAudioPlayer/setVolume(_:fadeDuration:))

Changes the audio player’s volume over a duration of time.

[`pan`](/documentation/AVFAudio/AVAudioPlayer/pan)

The audio player’s stereo pan position.

[`enableRate`](/documentation/AVFAudio/AVAudioPlayer/enableRate)

A Boolean value that indicates whether you can adjust the playback rate of the audio player.

[`rate`](/documentation/AVFAudio/AVAudioPlayer/rate)

The audio player’s playback rate.

[`numberOfLoops`](/documentation/AVFAudio/AVAudioPlayer/numberOfLoops)

The number of times the audio repeats playback.

### Accessing player timing

[`currentTime`](/documentation/AVFAudio/AVAudioPlayer/currentTime)

The current playback time, in seconds, within the audio timeline.

[`duration`](/documentation/AVFAudio/AVAudioPlayer/duration)

The total duration, in seconds, of the player’s audio.

### Configuring the Spatial Audio experience

[`intendedSpatialExperience`](/documentation/AVFAudio/AVAudioPlayer/intendedSpatialExperience-27klj)

The intended spatial experience for this player.   

[`intendedSpatialExperience`](/documentation/AVFAudio/AVAudioPlayer/intendedSpatialExperience-6py9z)

The intended spatial experience for this player.   

### Managing audio channels

[`numberOfChannels`](/documentation/AVFAudio/AVAudioPlayer/numberOfChannels)

The number of audio channels in the player’s audio.

[`channelAssignments`](/documentation/AVFAudio/AVAudioPlayer/channelAssignments)

An array of channel descriptions for the audio player.

### Managing audio-level metering

[`isMeteringEnabled`](/documentation/AVFAudio/AVAudioPlayer/isMeteringEnabled)

A Boolean value that indicates whether the player is able to generate audio-level metering data.

[`updateMeters()`](/documentation/AVFAudio/AVAudioPlayer/updateMeters())

Refreshes the average and peak power values for all channels of an audio player.

[`averagePower(forChannel:)`](/documentation/AVFAudio/AVAudioPlayer/averagePower(forChannel:))

Returns the average power, in decibels full-scale (dBFS), for an audio channel.

[`peakPower(forChannel:)`](/documentation/AVFAudio/AVAudioPlayer/peakPower(forChannel:))

Returns the peak power, in decibels full-scale (dBFS), for an audio channel.

### Responding to player events

[`delegate`](/documentation/AVFAudio/AVAudioPlayer/delegate)

The delegate object for the audio player.

[`AVAudioPlayerDelegate`](/documentation/AVFAudio/AVAudioPlayerDelegate)

A protocol that defines the methods to respond to audio playback events and decoding errors.

### Inspecting the audio data

[`url`](/documentation/AVFAudio/AVAudioPlayer/url)

The URL of the audio file.

[`data`](/documentation/AVFAudio/AVAudioPlayer/data)

The audio data associated with the player.

[`format`](/documentation/AVFAudio/AVAudioPlayer/format)

The format of the player’s audio data.

[`settings`](/documentation/AVFAudio/AVAudioPlayer/settings)

A dictionary that provides information about the player’s audio data.

### Accessing device information

[`currentDevice`](/documentation/AVFAudio/AVAudioPlayer/currentDevice)

The unique identifier of the current audio player.

[`deviceCurrentTime`](/documentation/AVFAudio/AVAudioPlayer/deviceCurrentTime)

The time value, in seconds, of the audio output device’s clock.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)
