public interface Music extends Disposable
A Music instance represents a streamed audio file. The interface supports pausing, resuming
and so on. When you are done with using the Music instance you have to dispose it via the dispose()
method.
Music instances are created via Audio.newMusic(FileHandle)
.
Music instances are automatically paused and resumed when an Application
is paused or resumed. See
ApplicationListener
.
Note: any values provided will not be clamped, it is the developer's responsibility to do so
Modifier and Type | Interface and Description |
---|---|
static interface |
Music.OnCompletionListener
Interface definition for a callback to be invoked when playback of a music stream has completed.
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Needs to be called when the Music is no longer needed.
|
float |
getPosition()
Returns the playback position in seconds.
|
float |
getVolume() |
boolean |
isLooping() |
boolean |
isPlaying() |
void |
pause()
Pauses the play back.
|
void |
play()
Starts the play back of the music stream.
|
void |
setLooping(boolean isLooping)
Sets whether the music stream is looping.
|
void |
setOnCompletionListener(Music.OnCompletionListener listener)
Register a callback to be invoked when the end of a music stream has been reached during playback.
|
void |
setPan(float pan,
float volume)
Sets the panning and volume of this music stream.
|
void |
setPosition(float position)
Set the playback position in seconds.
|
void |
setVolume(float volume)
Sets the volume of this music stream.
|
void |
stop()
Stops a playing or paused Music instance.
|
void play()
void pause()
void stop()
boolean isPlaying()
void setLooping(boolean isLooping)
isLooping
- whether to loop the streamboolean isLooping()
void setVolume(float volume)
volume
- float getVolume()
void setPan(float pan, float volume)
pan
- panning in the range -1 (full left) to 1 (full right). 0 is center position.volume
- the volume in the range [0,1].void setPosition(float position)
float getPosition()
void dispose()
dispose
in interface Disposable
void setOnCompletionListener(Music.OnCompletionListener listener)
listener
- the callback that will be run.Copyright © 2020. All rights reserved.