public interface Audio
| Modifier and Type | Method and Description |
|---|---|
void |
addMusicCompletionListener(MusicCompletionListener completionListener)
Adds a
MusicCompletionListener |
void |
addSoundCompletionListener(SoundCompletionListener completionListener)
Adds a
SoundCompletionListener |
AsyncSoundResult |
newAsyncSound(FileHandle fileHandle)
See
newSound(FileHandle). |
Music |
newMusic(byte[] bytes,
java.lang.String format)
Creates a new
Music instance used to play back an audio stream. |
default Music |
newMusic(FileHandle fileHandle)
Creates a new
Music instance used to play back an audio stream from a file. |
Music |
newMusic(FileHandle fileHandle,
boolean loadIntoMemory)
Creates a new
Music instance used to play back an audio stream. |
Sound |
newSound(FileHandle fileHandle)
Creates a new
Sound instance used to play back audio sound effects (e.g. |
void |
removeMusicCompletionListener(MusicCompletionListener completionListener)
Removes a
MusicCompletionListener |
void |
removeSoundCompletionListener(SoundCompletionListener completionListener)
Removes a
SoundCompletionListener |
Sound newSound(FileHandle fileHandle) throws java.io.IOException
Creates a new Sound instance used to play back audio sound effects (e.g. explosions, gunshots, etc.).
Note that the complete audio data is loaded into RAM and you should avoid loading large files.
The current upper limit for decoded audio is 1 MB.
Currently supported formats are WAV, MP3 and OGG.
When the Sound instance is no longer needed, call the Disposable.dispose() method
fileHandle - The FileHandle to load the audio fromSound instancejava.io.IOException - Thrown when the sound could not be loadedAsyncSoundResult newAsyncSound(FileHandle fileHandle)
newSound(FileHandle).
Loads a new Sound instance asynchronously.
On platforms not supporting async sound loading a warning will be logged and the sound would be loaded on game thread
when AsyncSoundResult.getResult() is called.
Supported platforms: Libgdx Desktop LWJGL2/3, Monogame.fileHandle - The FileHandle to load the audio fromAsyncSoundResult instance that's loading the sounddefault Music newMusic(FileHandle fileHandle) throws java.io.IOException
Creates a new Music instance used to play back an audio stream from a file.
Music instances are automatically paused when the application is paused and resumed when the application is resumed.
Currently supported formats are WAV, MP3 and OGG.
When the Music instance is no longer needed, call the Disposable.dispose() method
fileHandle - The FileHandle to stream the audio fromMusic instancejava.io.IOException - Thrown when the music could not be loadedMusic newMusic(FileHandle fileHandle, boolean loadIntoMemory) throws java.io.IOException
Creates a new Music instance used to play back an audio stream.
Music instances are automatically paused when the application is paused and resumed when the application is resumed.
Currently supported formats are WAV, MP3 and OGG.
When the Music instance is no longer needed, call the Disposable.dispose() method
fileHandle - The FileHandle to stream the audio fromloadIntoMemory - True if the file should be read into memory and streamed from memory. False, if streamed for disk.Music instancejava.io.IOException - Thrown when the music could not be loadedMusic newMusic(byte[] bytes, java.lang.String format) throws java.io.IOException
Creates a new Music instance used to play back an audio stream.
Music instances are automatically paused when the application is paused and resumed when the application is resumed.
Currently supported formats are WAV, MP3 and OGG.
When the Music instance is no longer needed, call the Disposable.dispose() method
bytes - The byte array to stream the audio fromformat - "ogg", "mp3" or "wav"Music instancejava.io.IOException - Thrown when the music could not be loadedvoid addMusicCompletionListener(MusicCompletionListener completionListener)
MusicCompletionListenercompletionListener - The MusicCompletionListener to be notified of Music completion events.void removeMusicCompletionListener(MusicCompletionListener completionListener)
MusicCompletionListenercompletionListener - The MusicCompletionListener to be removedvoid addSoundCompletionListener(SoundCompletionListener completionListener)
SoundCompletionListenercompletionListener - The SoundCompletionListener to be notified of Sound completion events.void removeSoundCompletionListener(SoundCompletionListener completionListener)
SoundCompletionListenercompletionListener - The SoundCompletionListener to be removed