SoundEffectPlayer


interface SoundEffectPlayer

Known direct subclasses
SoundEffectPoolComponent

Provides positional sound pool audio playback for an Entity.


Provides playback control for instances of SoundEffect.

Summary

Public functions

Unit
pause(stream: Stream)

Pauses a currently playing sound stream.

Stream
play(
    soundEffect: SoundEffect,
    volume: @FloatRange(from = 0.0, to = 1.0) Float,
    priority: @IntRange(from = 0) Int,
    isLooping: Boolean
)

Plays a loaded sound effect.

Unit
resume(stream: Stream)

Resumes a previously paused sound stream.

Unit
setLooping(stream: Stream, isLooping: Boolean)

Updates the looping status of an active stream.

Unit
setVolume(stream: Stream, volume: @FloatRange(from = 0.0, to = 1.0) Float)

Updates the volume of an active stream.

Unit
stop(stream: Stream)

Stops a currently playing or paused sound stream and releases that stream ID.

Public functions

pause

Added in 1.0.0-alpha15
fun pause(stream: Stream): Unit

Pauses a currently playing sound stream.

If the stream has already been stopped or released due to hitting the max stream count then this method has no effect.

Parameters
stream: Stream

a Stream returned by play

play

Added in 1.0.0-alpha15
fun play(
    soundEffect: SoundEffect,
    volume: @FloatRange(from = 0.0, to = 1.0) Float,
    priority: @IntRange(from = 0) Int,
    isLooping: Boolean
): Stream

Plays a loaded sound effect.

The SoundEffects can play concurrently up to the max stream count of the SoundEffectPool from which they were loaded. If the max stream count is exceeded, streams with lower priority are stopped first.

Parameters
soundEffect: SoundEffect

the handle to the loaded SoundEffect to play

volume: @FloatRange(from = 0.0, to = 1.0) Float

volume in the range 0.0 to 1.0

priority: @IntRange(from = 0) Int

playback priority (0 = lowest)

isLooping: Boolean

true to loop indefinitely, false to play once

Returns
Stream

a Stream for controlling this specific instance of the sound

Throws
RuntimeException

if the sound effect fails to play

resume

Added in 1.0.0-alpha15
fun resume(stream: Stream): Unit

Resumes a previously paused sound stream.

If the stream has already been stopped or released due to hitting the max stream count then this method has no effect.

Parameters
stream: Stream

a Stream returned by play

setLooping

Added in 1.0.0-alpha15
fun setLooping(stream: Stream, isLooping: Boolean): Unit

Updates the looping status of an active stream.

If the stream has already been stopped or released due to hitting the max stream count then this method has no effect.

Parameters
stream: Stream

a Stream returned by play

isLooping: Boolean

true to loop indefinitely, false to stop looping

setVolume

Added in 1.0.0-alpha15
fun setVolume(stream: Stream, volume: @FloatRange(from = 0.0, to = 1.0) Float): Unit

Updates the volume of an active stream.

If the stream has already been stopped or released due to hitting the max stream count then this method has no effect.

Parameters
stream: Stream

a Stream returned by play

volume: @FloatRange(from = 0.0, to = 1.0) Float

volume in the range 0.0 to 1.0

stop

Added in 1.0.0-alpha15
fun stop(stream: Stream): Unit

Stops a currently playing or paused sound stream and releases that stream ID.

If the stream has already been stopped or released due to hitting the max stream count then this method has no effect.

Parameters
stream: Stream

a Stream returned by play