| Constructor and Description |
|---|
LibgdxAudio() |
| Modifier and Type | Method and Description |
|---|---|
void |
addMusicCompletionListener(MusicCompletionListener completionListener)
Adds a
MusicCompletionListener |
void |
addSoundCompletionListener(SoundCompletionListener completionListener)
Adds a
SoundCompletionListener |
AsyncSoundResult |
newAsyncSound(FileHandle fileHandle)
|
Music |
newMusic(byte[] bytes,
java.lang.String format)
Creates a new
Music instance used to play back an audio stream. |
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 |
notifyMusicCompletionListeners(Music music) |
void |
notifySoundCompletionListeners(long soundId) |
void |
removeMusicCompletionListener(MusicCompletionListener completionListener)
Removes a
MusicCompletionListener |
void |
removeSoundCompletionListener(SoundCompletionListener completionListener)
Removes a
SoundCompletionListener |
public Sound newSound(FileHandle fileHandle) throws java.io.IOException
Audio
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
newSound in interface AudiofileHandle - The FileHandle to load the audio fromSound instancejava.io.IOException - Thrown when the sound could not be loadedpublic AsyncSoundResult newAsyncSound(FileHandle fileHandle)
AudioAudio.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.newAsyncSound in interface AudiofileHandle - The FileHandle to load the audio fromAsyncSoundResult instance that's loading the soundpublic Music newMusic(FileHandle fileHandle, boolean loadIntoMemory) throws java.io.IOException
Audio
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
newMusic in interface AudiofileHandle - 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 loadedpublic Music newMusic(byte[] bytes, java.lang.String format) throws java.io.IOException
Audio
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
public void addMusicCompletionListener(MusicCompletionListener completionListener)
AudioMusicCompletionListeneraddMusicCompletionListener in interface AudiocompletionListener - The MusicCompletionListener to be notified of Music completion events.public void removeMusicCompletionListener(MusicCompletionListener completionListener)
AudioMusicCompletionListenerremoveMusicCompletionListener in interface AudiocompletionListener - The MusicCompletionListener to be removedpublic void addSoundCompletionListener(SoundCompletionListener completionListener)
AudioSoundCompletionListeneraddSoundCompletionListener in interface AudiocompletionListener - The SoundCompletionListener to be notified of Sound completion events.public void removeSoundCompletionListener(SoundCompletionListener completionListener)
AudioSoundCompletionListenerremoveSoundCompletionListener in interface AudiocompletionListener - The SoundCompletionListener to be removedpublic void notifyMusicCompletionListeners(Music music)
public void notifySoundCompletionListeners(long soundId)