SoundEffectPlayer


public interface SoundEffectPlayer

Known direct subclasses
SoundEffectPoolComponent

Provides positional sound pool audio playback for an Entity.


Provides playback control for instances of SoundEffect.

Summary

Public methods

abstract void
pause(@NonNull Stream stream)

Pauses a currently playing sound stream.

abstract @NonNull Stream
play(
    @NonNull SoundEffect soundEffect,
    @FloatRange(from = 0.0, to = 1.0) float volume,
    @IntRange(from = 0) int priority,
    boolean isLooping
)

Plays a loaded sound effect.

abstract void

Resumes a previously paused sound stream.

abstract void
setLooping(@NonNull Stream stream, boolean isLooping)

Updates the looping status of an active stream.

abstract void
setVolume(
    @NonNull Stream stream,
    @FloatRange(from = 0.0, to = 1.0) float volume
)

Updates the volume of an active stream.

abstract void
stop(@NonNull Stream stream)

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

Public methods

pause

Added in 1.0.0-alpha15
abstract void pause(@NonNull Stream stream)

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
@NonNull Stream stream

a Stream returned by play

play

Added in 1.0.0-alpha15
abstract @NonNull Stream play(
    @NonNull SoundEffect soundEffect,
    @FloatRange(from = 0.0, to = 1.0) float volume,
    @IntRange(from = 0) int priority,
    boolean isLooping
)

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
@NonNull SoundEffect soundEffect

the handle to the loaded SoundEffect to play

@FloatRange(from = 0.0, to = 1.0) float volume

volume in the range 0.0 to 1.0

@IntRange(from = 0) int priority

playback priority (0 = lowest)

boolean isLooping

true to loop indefinitely, false to play once

Returns
@NonNull 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
abstract void resume(@NonNull Stream stream)

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
@NonNull Stream stream

a Stream returned by play

setLooping

Added in 1.0.0-alpha15
abstract void setLooping(@NonNull Stream stream, boolean isLooping)

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
@NonNull Stream stream

a Stream returned by play

boolean isLooping

true to loop indefinitely, false to stop looping

setVolume

Added in 1.0.0-alpha15
abstract void setVolume(
    @NonNull Stream stream,
    @FloatRange(from = 0.0, to = 1.0) float volume
)

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
@NonNull Stream stream

a Stream returned by play

@FloatRange(from = 0.0, to = 1.0) float volume

volume in the range 0.0 to 1.0

stop

Added in 1.0.0-alpha15
abstract void stop(@NonNull Stream stream)

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
@NonNull Stream stream

a Stream returned by play