SoundPlayer

Provides a simple class for playing sounds.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun adjustVolume(volume: Double)

Adjusts the volume of any currently playing clip. This adjustment will only affect the currently playing clip. The volume is specified using a normalised value between 0.0 (silence) and 1.0 (no attenuation).

Link copied to clipboard
fun playFromFile(path: String, volume: Double, loop: Boolean = false): SoundPlaybackResult

Play a sound from a file path. The volume is specified using a normalised value between 0.0 (silence) and 1.0 (no attenuation). If loop is set true the audio will loop indefinitely. Returns a result detailing if the operation was successful.

Link copied to clipboard
fun playFromResource(key: String, volume: Double, loop: Boolean = false): SoundPlaybackResult

Play a sound from a resource key. If volume is specified then the signal can be attenuated. The volume is specified using a normalised value between 0.0 (silence) and 1.0 (no attenuation). If loop is set true the audio will loop indefinitely. Returns a result detailing if the operation was successful.

Link copied to clipboard
fun stop()

Stop any playing audio.