playAudio(_:)
Prepares and plays a new audio playback instance on this entity.
Declaration
@discardableResult @MainActor @preconcurrency func playAudio(_ resource: AudioResource) -> AudioPlaybackControllerParameters
- resource:
The audio resource the method plays. Load an audio resource from the file system with Init(named:in:configuration:) , or from a URL with Init(contentsof:withname:configuration:).
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.