Class SoundResource

java.lang.Object
de.gurkenlabs.litiengine.resources.NamedResource
de.gurkenlabs.litiengine.resources.SoundResource
All Implemented Interfaces:
Resource, Comparable<Resource>

public class SoundResource extends NamedResource

Represents a sound resource that extends the NamedResource class.

This class is used to manage sound resources, including their data and format.

  • Constructor Details

    • SoundResource

      public SoundResource()

      Default constructor for SoundResource.

      This constructor doesn't do anything and is intended for XML serialization purposes.

    • SoundResource

      public SoundResource(Sound sound, SoundFormat format)

      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

      public String getData()

      Gets the encoded sound data.

      This method returns the encoded sound data as a string.

      Returns:
      The encoded sound data.
    • getFormat

      public SoundFormat getFormat()

      Gets the format of the sound.

      This method returns the format of the sound.

      Returns:
      The format of the sound.
    • setData

      public void setData(String data)

      Sets the encoded sound data.

      This method sets the encoded sound data.

      Parameters:
      data - The encoded sound data to set.
    • setFormat

      public void setFormat(SoundFormat format)

      Sets the format of the sound.

      This method sets the format of the sound.

      Parameters:
      format - The format of the sound to set.