com.flagstone.transform.util.sound
Class MP3Decoder

java.lang.Object
  extended by com.flagstone.transform.util.sound.MP3Decoder
All Implemented Interfaces:
SoundDecoder, SoundProvider

public final class MP3Decoder
extends Object
implements SoundProvider, SoundDecoder

Decoder for MP3 sounds so they can be added to a flash file.


Constructor Summary
MP3Decoder()
           
 
Method Summary
 DefineSound defineSound(int identifier)
          Define an event sound.
 DefineSound defineSound(int identifier, float duration)
          Define an event sound.
 SoundDecoder newDecoder()
          The method implemented by all SoundDecoders in order to be registered with the SoundRegistry and used by the SoundFactory to decode sounds.
 void read(File file)
          Read a sound from a file.
 void read(InputStream stream)
          Read a sound from an input stream.
 void read(URL url)
          Read a sound from a file referenced by a URL.
 MovieTag streamHeader(float frameRate)
          Generate the header for a streaming sound.
 MovieTag streamSound()
          Generate a SoundStreamBlock with next set of sound samples.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MP3Decoder

public MP3Decoder()
Method Detail

newDecoder

public SoundDecoder newDecoder()
The method implemented by all SoundDecoders in order to be registered with the SoundRegistry and used by the SoundFactory to decode sounds.

Specified by:
newDecoder in interface SoundProvider
Returns:
an object that implements the SoundDecoder interface.

read

public void read(File file)
          throws IOException,
                 DataFormatException
Read a sound from a file.

Specified by:
read in interface SoundDecoder
Parameters:
file - the path to the file.
Throws:
IOException - if there is an error reading the sound data.
DataFormatException - if the file contains an unsupported format.

read

public void read(URL url)
          throws IOException,
                 DataFormatException
Read a sound from a file referenced by a URL.

Specified by:
read in interface SoundDecoder
Parameters:
url - the reference to the file.
Throws:
IOException - if there is an error reading the sound data.
DataFormatException - if the file contains an unsupported format.

read

public void read(InputStream stream)
          throws IOException,
                 DataFormatException
Read a sound from an input stream.

Specified by:
read in interface SoundDecoder
Parameters:
stream - the stream used to read the sound data.
Throws:
IOException - if there is an error reading the sound data.
DataFormatException - if the file contains an unsupported format.

defineSound

public DefineSound defineSound(int identifier)
                        throws IOException,
                               DataFormatException
Define an event sound.

Specified by:
defineSound in interface SoundDecoder
Parameters:
identifier - he unique identifier that will be used to reference the sound in a Movie.
Returns:
the definition used to add the sound to a Movie.
Throws:
IOException - if there is an error reading the sound data.
DataFormatException - if the file contains an unsupported format.

defineSound

public DefineSound defineSound(int identifier,
                               float duration)
                        throws IOException,
                               DataFormatException
Define an event sound.

Specified by:
defineSound in interface SoundDecoder
Parameters:
identifier - the unique identifier that will be used to reference the sound in a Movie.
duration - the number of seconds to play the sound for.
Returns:
the definition used to add the sound to a Movie.
Throws:
IOException - if there is an error reading the sound data.
DataFormatException - if the file contains an unsupported format.

streamHeader

public MovieTag streamHeader(float frameRate)
Generate the header for a streaming sound.

Specified by:
streamHeader in interface SoundDecoder
Parameters:
frameRate - the frame rate for the movie so the sound can be divided into sets of samples that can be played with each frame.
Returns:
the stream header object that contains information about the sound.

streamSound

public MovieTag streamSound()
                     throws IOException,
                            DataFormatException
Generate a SoundStreamBlock with next set of sound samples.

Specified by:
streamSound in interface SoundDecoder
Returns:
a SoundStreamBlock containing the sound samples or null if there are no more samples to available.
Throws:
IOException - if there is an error reading the sound data.
DataFormatException - if the file contains an unsupported format.


Copyright © 2002-2010 Flagstone Software Ltd.. All Rights Reserved.