@MainActor @preconcurrency class AudioBufferResource
An audio resource that you load from an <doc://com.apple.documentation/documentation/avfaudio/avaudiobuffer>.
Use the resource to create an ``AudioPlaybackController`` instance by calling an entity’s ``Entity/prepareAudio(_:)`` or ``Entity/playAudio(_:)`` function.
The controller plays the audio from the location in space of the entity that created the controller.
Members (5)
get · iOS 15.0+ · Deprecated in iOS 18.0
shouldLoop
TypeScript
get shouldLoop(): Promise<boolean>
Swift declaration
@MainActor @preconcurrency var shouldLoop: Bool { get }
Whether or not this file loops during playback. This should be set for assets
that are prepared as seamless loops. A looping resource will play forever until it is
explicitly told to stop.
get · iOS 18.0+
configuration
TypeScript
get configuration(): Promise<AudioBufferResource_Configuration>
Swift declaration
@MainActor @preconcurrency final let configuration: AudioBufferResource.Configuration
Creates an `AudioBufferResource` with the given `AVAudioBuffer` and configuration.
- Throws: An error if the given `buffer` is not or cannot be converted to a non-interleaved PCM buffer.
Init an AudioBufferResource from an `AVAudioBuffer` instead of a file location. This is intended for use with `AVSpeechSynthesisVoice`.
- Parameter from: The `AVAudioBuffer` containing PCM audio data to be loaded as an `AudioResource`.
- Parameter inputMode: How the audio engine processes a resource. nonSpatial, spatial, ambient
- Parameter shouldLoop: Bool value to decide if the audio clip should loop
- Throws: This function throws an error when the `AVAudioBuffer` cannot be cast or converted to `AVAudioPCMBuffer`.
get · iOS 18.0+
duration
TypeScript
get duration(): Promise<SDKHandle>
Swift declaration
@MainActor @preconcurrency var duration: Duration { get }