Contents

AudioPlaybackController

A controller that manages an audio playback instance.

Declaration

@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. To play multiple instances of a resource, call 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.

After playback completes, or if you call the 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 if you want to be alerted when certain aspects of audio playback occur.

Topics

Managing the resource

Setting the volume

Setting the speed

Setting the reverb

Starting and stopping audio playback

Handling completion

Finding the associated entity

Instance Methods

Type Aliases

See Also

Playback controllers