Package de.gurkenlabs.litiengine.sound
Class Sound
java.lang.Object
de.gurkenlabs.litiengine.sound.Sound
public final class Sound
extends java.lang.Object
This class implements all required functionality to load sounds from the file
system and provide a stream that can later on be used for the sound playback.
Constructor Summary
Constructors Constructor Description Sound(java.io.InputStream is, java.lang.String name)
Creates a new Sound instance by the specified file path.Method Summary
Modifier and Type Method Description javax.sound.sampled.AudioFormat
getFormat()
Gets the audio format of this sound instance.java.lang.String
getName()
Gets the name of this instance that is used to uniquely identify the resource of this sound.byte[]
getRawData()
Gets the raw data of this sound as byte array.java.lang.String
toString()
Constructor Details
Sound
public Sound(java.io.InputStream is, java.lang.String name) throws java.io.IOException, javax.sound.sampled.UnsupportedAudioFileExceptionCreates a new Sound instance by the specified file path. Loads the sound data into a byte array and also retrieves information about the format of the sound file. Note that the constructor is private. In order to load files use the staticResources.sounds().get(String)
method.- Parameters:
is
- The input stream to load the sound from.name
- The name of this sound file.- Throws:
java.io.IOException
- If something went wrong loading the filejavax.sound.sampled.UnsupportedAudioFileException
- If the audio format is not supported
Method Details
getFormat
public javax.sound.sampled.AudioFormat getFormat()Gets the audio format of this sound instance.- Returns:
- The audio format of this instance.
getName
public java.lang.String getName()Gets the name of this instance that is used to uniquely identify the resource of this sound.- Returns:
- The name of this sound.
getRawData
public byte[] getRawData()Gets the raw data of this sound as byte array.This is used during resource serialization.
- Returns:
- The raw data of this sound as byte array.
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object