com.flagstone.transform.util.sound
Class SoundFactory

java.lang.Object
  extended by com.flagstone.transform.util.sound.SoundFactory

public final class SoundFactory
extends Object

SoundFactory is used to generate the objects representing an event or streaming sound from an sound stored in a file, references by a URL or read from an stream. An plug-in architecture allows decoders to be registered to handle different formats. The SoundFactory provides a standard interface for using the different decoders for each supported sound format.


Constructor Summary
SoundFactory()
           
 
Method Summary
 DefineSound defineSound(int identifier)
          Create a definition for an event sound that can be added to a Flash movie.
 DefineSound defineSound(int identifier, float duration)
          Create a definition for an event sound that can be added to a Flash movie.
 void read(File file)
          Decode a sound located in the specified file.
 void read(InputStream stream)
          Decode a sound from a stream.
 void read(URL url)
          Decode a sound 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

SoundFactory

public SoundFactory()
Method Detail

read

public void read(File file)
          throws IOException,
                 DataFormatException
Decode a sound located in the specified file.

Parameters:
file - a file containing the abstract path to the sound.
Throws:
IOException - if there is an error reading the file.
DataFormatException - if there is a problem decoding the sound, either it is in an unsupported format or an error occurred while decoding the sound data.

read

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

Parameters:
url - the Uniform Resource Locator referencing the file.
Throws:
IOException - if there is an error reading the file.
DataFormatException - if there is a problem decoding the sound, either it is in an unsupported format or an error occurred while decoding the sound data.

read

public void read(InputStream stream)
          throws IOException,
                 DataFormatException
Decode a sound from a stream.

Parameters:
stream - the InputStream containing the sound data.
Throws:
IOException - if there is an error reading the stream.
DataFormatException - if there is a problem decoding the sound, either it is in an unsupported format or an error occurred while decoding the sound data.

defineSound

public DefineSound defineSound(int identifier)
                        throws IOException,
                               DataFormatException
Create a definition for an event sound that can be added to a Flash movie.

Parameters:
identifier - the unique identifier for the sound.
Returns:
a DefineSound object containing the image definition.
Throws:
IOException - if there is an error reading the file.
DataFormatException - if there is a problem decoding the sound, either it is in an unsupported format or an error occurred while decoding the sound data.

defineSound

public DefineSound defineSound(int identifier,
                               float duration)
                        throws IOException,
                               DataFormatException
Create a definition for an event sound that can be added to a Flash movie.

Parameters:
identifier - the unique identifier for the sound.
duration - the number of seconds to play the sound for.
Returns:
a DefineSound object containing the image definition.
Throws:
IOException - if there is an error reading the file.
DataFormatException - if there is a problem decoding the sound, either it is in an unsupported format or an error occurred while decoding the sound data.

streamHeader

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

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:
a SoundStreamHead2 object that defines the streaming sound.

streamSound

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

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.