@MainActor @preconcurrency class AudioFileResource
An audio resource that you load from a file or from a URL.
Load an audio file resource, like an audio file stored in .aiff or other format, by calling one of the load functions.
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.
Initializes an AudioFileResource asynchronously.
- Important: The name provided **must** be unique.
get · iOS 13.0+ · Deprecated in iOS 18.0
shouldLoop
TypeScript
get shouldLoop(): Promise<boolean>
Swift declaration
@MainActor @preconcurrency var shouldLoop: Bool { get set }
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.
set · iOS 13.0+ · Deprecated in iOS 18.0
shouldLoop
TypeScript
setShouldLoop(value: boolean): Promise<void>
Swift declaration
@MainActor @preconcurrency var shouldLoop: Bool { get set }
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<AudioFileResource_Configuration>
Swift declaration
@MainActor @preconcurrency final let configuration: AudioFileResource.Configuration
The configuration of this `AudioFileResource`.
get · iOS 13.0+ · Deprecated in iOS 18.0
loadingStrategy
TypeScript
get loadingStrategy(): Promise<AudioFileResource_LoadingStrategy>
Swift declaration
@MainActor @preconcurrency var loadingStrategy: AudioFileResource.LoadingStrategy { get set }
Initializes an AudioFileResource from in-memory data asynchronously.
This API creates a memory-resident audio resource that never writes to disk.
The data must contain a valid audio file format (WAV, M4A, etc.).
- Parameters:
- data: The audio file data in memory
- configuration: Configuration settings for the audio resource
- Throws: `AudioFileResource.Error` if the data is invalid or cannot be processed
@MainActor @preconcurrency static func load(named name: String, from scene: String, in bundle: Bundle? = nil) throws -> AudioFileResource
Loads a preconfigured AudioFileResource from a Reality Composer Pro project with the given
`name` as the the prim-path of the AudioFile, and the `scene` as the name of the
USD file name.
- Important: The name provided **must** be unique.
@MainActor @preconcurrency convenience init(named name: String, from scene: String, in bundle: Bundle? = nil) async throws
Initializes a preconfigured AudioFileResource asynchronously from a Reality Composer Pro project
with the given `name` as the the prim-path of the AudioFile, and the `scene` as
the name of the USD file name.
- Important: The name provided **must** be unique.
get · iOS 18.0+
duration
TypeScript
get duration(): Promise<SDKHandle>
Swift declaration
@MainActor @preconcurrency var duration: Duration { get }