Instance Method

playAudio(_:)

Plays sound from an audio resource on this entity.

Declaration

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

Parameters

resource

The audio resource to play. You typically use the loadAsync(named:in:inputMode:loadingStrategy:loops:) method to get a resource from a file on disk, or the loadAsync(contentsOf:withName:inputMode:loadingStrategy:loops:) method to retrieve a resource from a URL.

Return Value

An AudioPlaybackController instance that you use to manage audio playback. Use the controller to set playback characteristics like volume and reverb, and then start or stop playback.

Discussion

This method first prepares the audio by calling prepareAudio(_:), and then immediately calls the play() method on the returned controller.

See Also

Playing Audio

func prepareAudio(AudioResource) -> AudioPlaybackController

Prepares an audio resource for playback.

func stopAllAudio()

Stops audio playback.