Contents

playAudio(_:)

Prepares and plays a new audio playback instance on this entity.

Declaration

@discardableResult @MainActor @preconcurrency func playAudio(_ resource: AudioResource) -> AudioPlaybackController

Parameters

Return Value

An AudioPlaybackController object that you can use to start and stop audio playback for this specific instance of a resource playing on this entity. You can also use this controller to update playback properties, such as gain and speed, during playback.

Discussion

The method prepares the audio by calling prepareAudio(_:), and then immediately calls the play() method of the controller that it returns. To begin multiple playback instances you can call playAudio multiple times.

See Also

Playing audio