Type Method

audioPlayerWithSource:

Returns an audio player (creating one if necessary) to play a simple audio source.

Declaration

+ (instancetype)audioPlayerWithSource:(SCNAudioSource *)source;

Parameters

source

An audio source object.

Return Value

A positional audio player object.

Discussion

An SCNAudioSource object represents a distinct source of audio (for example, a sound file) that can be reused and shared by many player objects. Use this method to create an audio player from such a source. When you use this method, SceneKit creates an audio player for the specified SCNAudioSource object or, if an audio player for that source already exists and is not in use, SceneKit reuses the existing player object.

If instead you want to attach a more complex audio setup to a position in your scene—such as a mixer that varies several audio inputs in response to user input—build that setup using AVAudioNode objects and create a player for it with the audioPlayerWithAVAudioNode: method.

See Also

Creating an Audio Player

- initWithSource:

Initializes an audio player for playing the specified simple audio source.

- initWithAVAudioNode:

Initializes an audio player for playing the specified AVFoundation audio node.

+ audioPlayerWithAVAudioNode:

Returns an audio player (creating one if necessary) to play an audio node.