public interface Audio
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 |
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 loadedMusic 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 loadedvoid addMusicCompletionListener(MusicCompletionListener completionListener)
MusicCompletionListener
completionListener
- The MusicCompletionListener
to be notified of Music
completion events.void removeMusicCompletionListener(MusicCompletionListener completionListener)
MusicCompletionListener
completionListener
- The MusicCompletionListener
to be removedvoid addSoundCompletionListener(SoundCompletionListener completionListener)
SoundCompletionListener
completionListener
- The SoundCompletionListener
to be notified of Sound
completion events.void removeSoundCompletionListener(SoundCompletionListener completionListener)
SoundCompletionListener
completionListener
- The SoundCompletionListener
to be removed