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 | Class and Description |
|---|---|
| public static interface | Music.
Interface definition for a callback to be invoked when playback of a music stream has completed. |
| Modifier and Type | Method and Description |
|---|---|
| public void | dispose()
Redeclares com. Needs to be called when the Music is no longer needed. |
| public float | |
| public float | |
| public boolean | |
| public boolean | |
| public void | |
| public void | |
| public void | |
| public void | setOnCompletionListener(Music.
the callback that will be run. listenerRegister a callback to be invoked when the end of a music stream has been reached during playback. |
| public void | setPan(float
panning in the range -1 (full left) to 1 (full right). 0 is center position. pan, float the volume in the range [0,1]. volume)Sets the panning and volume of this music stream. |
| public void | |
| public void | |
| public void |
| dispose | back to summary |
|---|---|
| public void dispose() Redeclares com. Needs to be called when the Music is no longer needed. | |
| getPosition | back to summary |
|---|---|
| public float getPosition() Returns the playback position in seconds. | |
| getVolume | back to summary |
|---|---|
public float getVolume()
| |
| isLooping | back to summary |
|---|---|
public boolean isLooping()
| |
| isPlaying | back to summary |
|---|---|
public boolean isPlaying()
| |
| pause | back to summary |
|---|---|
| public void pause() Pauses the play back. If the music stream has not been started yet or has finished playing a call to this method will be ignored. | |
| play | back to summary |
|---|---|
| public void play() Starts the play back of the music stream. In case the stream was paused this will resume the play back. In case the music stream is finished playing this will restart the play back. | |
| setLooping | back to summary |
|---|---|
| public void setLooping(boolean isLooping) Sets whether the music stream is looping. This can be called at any time, whether the stream is playing.
| |
| setOnCompletionListener | back to summary |
|---|---|
| public void setOnCompletionListener(Music. Register a callback to be invoked when the end of a music stream has been reached during playback.
| |
| setPan | back to summary |
|---|---|
| public void setPan(float pan, float volume) Sets the panning and volume of this music stream.
| |
| setPosition | back to summary |
|---|---|
| public void setPosition(float position) Set the playback position in seconds. | |
| setVolume | back to summary |
|---|---|
| public void setVolume(float volume) Sets the volume of this music stream. The volume must be given in the range [0,1] with 0 being silent and 1 being the maximum volume. | |
| stop | back to summary |
|---|---|
| public void stop() Stops a playing or paused Music instance. Next time play() is invoked the Music will start from the beginning. | |
| Modifier and Type | Method and Description |
|---|---|
| public void | onCompletion(Music
the Music that reached the end of the file music)Called when the end of a media source is reached during playback. |
| onCompletion | back to summary |
|---|---|
| public void onCompletion(Music music) Called when the end of a media source is reached during playback.
| |