One Logo Pool Ball
RealityFoundation · IOS API REFERENCE

AudioFileResource

class · iOS 13.0+ · SDK 27.1

@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.

Members (18)

init · iOS 18.0+

init

TypeScript
static initContentsOfWithNameConfiguration(url: string, resourceName?: (string) | null, configuration?: AudioFileResource_Configuration): Promise<AudioFileResource>
Swift declaration
@MainActor @preconcurrency convenience init(contentsOf url: URL, withName resourceName: String? = nil, configuration: AudioFileResource.Configuration = .init()) async throws

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 }

The resource's memory model.

set · iOS 13.0+ · Deprecated in iOS 18.0

loadingStrategy

TypeScript
setLoadingStrategy(value: AudioFileResource_LoadingStrategy): Promise<void>
Swift declaration
@MainActor @preconcurrency var loadingStrategy: AudioFileResource.LoadingStrategy { get set }

The resource's memory model.

init · iOS 27.0+

init

TypeScript
static initFromConfiguration(data: ArrayBuffer, configuration?: AudioFileResource_Configuration): Promise<AudioFileResource>
Swift declaration
@MainActor @preconcurrency convenience init(from data: Data, configuration: AudioFileResource.Configuration = .init()) async throws

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

static · iOS 18.0+

load

TypeScript
static loadContentsOfWithNameConfiguration(url: string, name?: (string) | null, configuration?: AudioFileResource_Configuration): Promise<AudioFileResource>
Swift declaration
@MainActor @preconcurrency static func load(contentsOf url: URL, withName name: String? = nil, configuration: AudioFileResource.Configuration = .init()) throws -> AudioFileResource

Loads an AudioFileResource synchronously. - Important: The name provided **must** be unique.

static · iOS 13.0+ · Deprecated in iOS 18.0

load

TypeScript
static loadContentsOfWithNameInputModeLoadingStrategyShouldLoop(url: string, resourceName?: (string) | null, inputMode?: AudioResource_InputMode, loadingStrategy?: AudioFileResource_LoadingStrategy, shouldLoop?: boolean): Promise<AudioFileResource>
Swift declaration
@MainActor @preconcurrency static func load(contentsOf url: URL, withName resourceName: String? = nil, inputMode: AudioResource.InputMode = .spatial, loadingStrategy: AudioFileResource.LoadingStrategy = .preload, shouldLoop: Bool = false) throws -> AudioFileResource

Synchronously loads an audio resource.

static · iOS 18.0+

load

TypeScript
static loadNamedInConfiguration(name: string, bundle?: (_Foundation_Bundle) | null, configuration?: AudioFileResource_Configuration): Promise<AudioFileResource>
Swift declaration
@MainActor @preconcurrency static func load(named name: String, in bundle: Bundle? = nil, configuration: AudioFileResource.Configuration = .init()) throws -> AudioFileResource

Loads an AudioFileResource synchronously. - Important: The name provided **must** be unique.

static · iOS 13.0+ · Deprecated in iOS 18.0

load

TypeScript
static loadNamedInInputModeLoadingStrategyShouldLoop(name: string, bundle?: (_Foundation_Bundle) | null, inputMode?: AudioResource_InputMode, loadingStrategy?: AudioFileResource_LoadingStrategy, shouldLoop?: boolean): Promise<AudioFileResource>
Swift declaration
@MainActor @preconcurrency static func load(named name: String, in bundle: Bundle? = nil, inputMode: AudioResource.InputMode = .spatial, loadingStrategy: AudioFileResource.LoadingStrategy = .preload, shouldLoop: Bool = false) throws -> AudioFileResource

Synchronously loads an audio resource.

static · iOS 18.0+

load

TypeScript
static loadNamedFromIn(name: string, scene: string, bundle?: (_Foundation_Bundle) | null): Promise<AudioFileResource>
Swift declaration
@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.

get · iOS 13.0+

name

TypeScript
get name(): Promise<string>
Swift declaration
@MainActor @preconcurrency final let name: String

The name of this `AudioFileResource`.

init · iOS 18.0+

init

TypeScript
static initNamedInConfiguration(name: string, bundle?: (_Foundation_Bundle) | null, configuration?: AudioFileResource_Configuration): Promise<AudioFileResource>
Swift declaration
@MainActor @preconcurrency convenience init(named name: String, in bundle: Bundle? = nil, configuration: AudioFileResource.Configuration = .init()) async throws

Initializes an AudioFileResource asynchronously. - Important: The name provided **must** be unique.

init · iOS 18.0+

init

TypeScript
static initNamedFromIn(name: string, scene: string, bundle?: (_Foundation_Bundle) | null): Promise<AudioFileResource>
Swift declaration
@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 }

The duration of this `AudioFileResource`.

static · iOS 13.0+ · Deprecated in iOS 18.0

loadAsync

TypeScript
static loadAsyncContentsOfWithNameInputModeLoadingStrategyShouldLoop(url: string, resourceName?: (string) | null, inputMode?: AudioResource_InputMode, loadingStrategy?: AudioFileResource_LoadingStrategy, shouldLoop?: boolean): Promise<LoadRequest<AudioFileResource>>
Swift declaration
@MainActor @preconcurrency static func loadAsync(contentsOf url: URL, withName resourceName: String? = nil, inputMode: AudioResource.InputMode = .spatial, loadingStrategy: AudioFileResource.LoadingStrategy = .preload, shouldLoop: Bool = false) -> LoadRequest<AudioFileResource>
static · iOS 13.0+ · Deprecated in iOS 18.0

loadAsync

TypeScript
static loadAsyncNamedInInputModeLoadingStrategyShouldLoop(name: string, bundle?: (_Foundation_Bundle) | null, inputMode?: AudioResource_InputMode, loadingStrategy?: AudioFileResource_LoadingStrategy, shouldLoop?: boolean): Promise<LoadRequest<AudioFileResource>>
Swift declaration
@MainActor @preconcurrency static func loadAsync(named name: String, in bundle: Bundle? = nil, inputMode: AudioResource.InputMode = .spatial, loadingStrategy: AudioFileResource.LoadingStrategy = .preload, shouldLoop: Bool = false) -> LoadRequest<AudioFileResource>

Skipped declarations

No declarations were skipped in this snapshot.

All RealityFoundation types →