Constructor and Description |
---|
LibgdxAudio() |
Modifier and Type | Method and Description |
---|---|
void |
addMusicCompletionListener(MusicCompletionListener completionListener)
Adds a
MusicCompletionListener |
void |
addSoundCompletionListener(SoundCompletionListener completionListener)
Adds a
SoundCompletionListener |
Music |
newMusic(FileHandle fileHandle)
Creates a new
Music instance used to play back an audio stream from a file. |
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 Audio
fileHandle
- The FileHandle
to load the audio fromSound
instancejava.io.IOException
- Thrown when the sound could not be loadedpublic Music newMusic(FileHandle fileHandle) throws java.io.IOException
Audio
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
newMusic
in interface Audio
fileHandle
- The FileHandle
to stream the audio fromMusic
instancejava.io.IOException
- Thrown when the music could not be loadedpublic void addMusicCompletionListener(MusicCompletionListener completionListener)
Audio
MusicCompletionListener
addMusicCompletionListener
in interface Audio
completionListener
- The MusicCompletionListener
to be notified of Music
completion events.public void removeMusicCompletionListener(MusicCompletionListener completionListener)
Audio
MusicCompletionListener
removeMusicCompletionListener
in interface Audio
completionListener
- The MusicCompletionListener
to be removedpublic void addSoundCompletionListener(SoundCompletionListener completionListener)
Audio
SoundCompletionListener
addSoundCompletionListener
in interface Audio
completionListener
- The SoundCompletionListener
to be notified of Sound
completion events.public void removeSoundCompletionListener(SoundCompletionListener completionListener)
Audio
SoundCompletionListener
removeSoundCompletionListener
in interface Audio
completionListener
- The SoundCompletionListener
to be removedpublic void notifyMusicCompletionListeners(Music music)
public void notifySoundCompletionListeners(long soundId)