- All Superinterfaces:
Asset
AudioClip defines the api for audio
Asset
s.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addFinishListener
(Consumer<AudioClip> callback) Called when an AudioClip completes playing.void
dispose()
Frees up any system resources being used.float
boolean
default void
loop()
Continues playing the AudioClip until pause or stop is called.void
loop
(int times) Continues playing the AudioClip for a number of times or until pause or stop is called.void
pause()
Pauses playback.void
play()
Begins or resumes playback.void
setVolume
(float volume) Sets the volume where 0 is silent and 1 is full volume.void
stop()
Stops audio playback.
-
Field Details
-
CONTINUOUS_LOOPING
static final int CONTINUOUS_LOOPING- See Also:
-
-
Method Details
-
isPlaying
boolean isPlaying()- Returns:
- True if currently playing audio
-
play
void play()Begins or resumes playback. -
pause
void pause()Pauses playback. AudioClip will resume where it was paused when play is called next. -
stop
void stop()Stops audio playback. AudioClip will start from the beginning when play is called next. -
loop
default void loop()Continues playing the AudioClip until pause or stop is called. -
loop
void loop(int times) Continues playing the AudioClip for a number of times or until pause or stop is called. If times is set toCONTINUOUS_LOOPING
it will play until pause or stop is called.- Parameters:
times
- how many times the AudioClip should loop
-
getVolume
float getVolume()- Returns:
- volume where 0 is silent and 1 is full volume
-
setVolume
void setVolume(float volume) Sets the volume where 0 is silent and 1 is full volume.- Parameters:
volume
- the new volume
-
dispose
void dispose()Frees up any system resources being used. -
addFinishListener
Called when an AudioClip completes playing.- Parameters:
callback
-Consumer
that provides the AudioClip that finished
-