Class SoundResource
- All Implemented Interfaces:
Resource, Comparable<Resource>
Represents a sound resource that extends the NamedResource class.
This class is used to manage sound resources, including their data and format.
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for SoundResource.SoundResource(Sound sound, SoundFormat format) Constructs a new SoundResource with the specified sound and format.SoundResource(InputStream data, String name, SoundFormat format) Constructs a new SoundResource with the specified input stream, name, and format. -
Method Summary
Modifier and TypeMethodDescriptiongetData()Gets the encoded sound data.Gets the format of the sound.voidSets the encoded sound data.voidsetFormat(SoundFormat format) Sets the format of the sound.Methods inherited from class NamedResource
getName, setName
-
Constructor Details
-
SoundResource
public SoundResource()Default constructor for SoundResource.
This constructor doesn't do anything and is intended for XML serialization purposes.
-
SoundResource
Constructs a new SoundResource with the specified sound and format.
This constructor initializes the SoundResource with the provided Sound object and SoundFormat. It sets the name of the resource to the name of the sound and encodes the raw data of the sound.
- Parameters:
sound- The Sound object to be used for this resource.format- The format of the sound.
-
SoundResource
public SoundResource(InputStream data, String name, SoundFormat format) throws IOException, UnsupportedAudioFileException Constructs a new SoundResource with the specified input stream, name, and format.
This constructor initializes the SoundResource by creating a new Sound object from the provided input stream and name, and sets the format of the sound.
- Parameters:
data- The input stream containing the sound data.name- The name of the sound.format- The format of the sound.- Throws:
IOException- If an I/O error occurs while reading the sound data.UnsupportedAudioFileException- If the audio file format is not supported.
-
-
Method Details
-
getData
Gets the encoded sound data.
This method returns the encoded sound data as a string.
- Returns:
- The encoded sound data.
-
getFormat
Gets the format of the sound.
This method returns the format of the sound.
- Returns:
- The format of the sound.
-
setData
Sets the encoded sound data.
This method sets the encoded sound data.
- Parameters:
data- The encoded sound data to set.
-
setFormat
Sets the format of the sound.
This method sets the format of the sound.
- Parameters:
format- The format of the sound to set.
-