<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/AudioPlaybackController",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation23AudioPlaybackControllerC"
  },
  "title" : "AudioPlaybackController"
}
-->

# AudioPlaybackController

A controller that manages an audio playback instance.

```
@MainActor @preconcurrency class AudioPlaybackController
```

## Overview

You can obtain an audio playback controller by calling an entity’s Entity/prepareAudio(*:) or Entity/playAudio(*:) method
which creates a controller with the associated [`AudioResource`](/documentation/RealityKit/AudioResource).
To play multiple instances of a resource, call [`playAudio(_:)`](/documentation/RealityKit/Entity/playAudio(_:)) to obtain new AudioPlaybackControllers.

During playback, the audio appears to come from the entity that you used to
create the controller. As you move around the MR scene, RealityKit
modulates the characteristics of the audio to account for your
location.

> Note: Playback commences only after the entity is parented and placed within a scene.

After playback completes, or if you call the
[`stop()`](/documentation/RealityKit/AudioPlaybackController/stop()) method, the audio resource resets,
allowing you to replay the resource from the beginning. Alternatively, you can
enable indefinite looping by setting the `loops` property of
the audio resource to `true`.

Look for one of the events in [`AudioEvents`](/documentation/RealityKit/AudioEvents) if you want to be alerted when
certain aspects of audio playback occur.

## Topics

### Managing the resource

[`resource`](/documentation/RealityKit/AudioPlaybackController/resource)

The resource that provides the audio stream.

### Setting the volume

[`gain`](/documentation/RealityKit/AudioPlaybackController/gain)

The individual gain in decibels of the audio playback controller output.

[`fade(to:duration:)`](/documentation/RealityKit/AudioPlaybackController/fade(to:duration:))

Transitions the gain to the given value over a time interval using a
linear curve.

### Setting the speed

[`speed`](/documentation/RealityKit/AudioPlaybackController/speed)

The rate of playback of the audio resource, with a range of `[.25, 4]`

### Setting the reverb

[`reverbSendLevel`](/documentation/RealityKit/AudioPlaybackController/reverbSendLevel)

The send level from this playback controller to the reverb system.

### Starting and stopping audio playback

[`play()`](/documentation/RealityKit/AudioPlaybackController/play())

Plays the audio resource.

[`pause()`](/documentation/RealityKit/AudioPlaybackController/pause())

Pauses playback of the audio resource while maintaining the position in
the audio stream.

[`stop()`](/documentation/RealityKit/AudioPlaybackController/stop())

Stops playback of the audio resource and discards the location in the
audio stream.

[`isPlaying`](/documentation/RealityKit/AudioPlaybackController/isPlaying)

A Boolean value that indicates whether playback is currently active.

### Handling completion

[`completionHandler`](/documentation/RealityKit/AudioPlaybackController/completionHandler)

A closure that the playback controller executes when it reaches the end
of the audio stream.

### Finding the associated entity

[`entity`](/documentation/RealityKit/AudioPlaybackController/entity)

The entity from which the audio stream emanates.

### Scheduling audio playback

[`play(at:)`](/documentation/RealityKit/AudioPlaybackController/play(at:))

Plays the audio resource asynchronously at a specified time.



---

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)