kiwi.ui
Class AudioClip

java.lang.Object
  extended bykiwi.ui.AudioClip
All Implemented Interfaces:
java.applet.AudioClip

public class AudioClip
extends java.lang.Object
implements java.applet.AudioClip

This class represents an audio clip. The audio data is restricted to the 8000Hz, single-channel u-law format. The class relies on the undocumented sun.audio package and thus may not be portable.

AudioClips may be read from streams, from files, or loaded as system resources using a ResourceManager or ResourceLoader.

Author:
Mark Lindner, PING Software Group
See Also:
ResourceManager.getSound(java.lang.String), ResourceLoader.getResourceAsURL(java.lang.String)

Field Summary
private  sun.audio.AudioData audioData
           
private  sun.audio.AudioDataStream audioStream
           
private  sun.audio.ContinuousAudioDataStream cAudioStream
           
(package private) static int length
           
private  java.lang.String name
           
 
Constructor Summary
AudioClip(java.io.InputStream stream)
          Construct a new AudioClip.
AudioClip(java.lang.String file)
          Construct a new AudioClip.
AudioClip(java.net.URL url)
          Construct a new AudioClip.
 
Method Summary
 java.lang.String getName()
          Get the audio clip's name.
 void loop()
          Play the audio clip continuously.
 void play()
          Play the audio clip.
 void setName(java.lang.String name)
          Set the audio clip's name.
 void stop()
          Stop playing the audio clip.
 java.lang.String toString()
          Get a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

length

static int length

audioData

private sun.audio.AudioData audioData

audioStream

private sun.audio.AudioDataStream audioStream

cAudioStream

private sun.audio.ContinuousAudioDataStream cAudioStream

name

private java.lang.String name
Constructor Detail

AudioClip

public AudioClip(java.net.URL url)
          throws java.io.IOException
Construct a new AudioClip.

Parameters:
url - The location of the audio data.
Throws:
java.io.IOException - If there is a problem reading from the specified URL.

AudioClip

public AudioClip(java.lang.String file)
          throws java.io.IOException
Construct a new AudioClip.

Throws:
java.io.IOException - If there is a problem reading from the specified file.

AudioClip

public AudioClip(java.io.InputStream stream)
          throws java.io.IOException
Construct a new AudioClip.

Parameters:
stream - The stream to read the audio data from.
Throws:
java.io.IOException - If there is a problem reading from the specified stream.
Method Detail

play

public void play()
Play the audio clip.

Specified by:
play in interface java.applet.AudioClip

loop

public void loop()
Play the audio clip continuously.

Specified by:
loop in interface java.applet.AudioClip

stop

public void stop()
Stop playing the audio clip.

Specified by:
stop in interface java.applet.AudioClip

setName

public void setName(java.lang.String name)
Set the audio clip's name.

Parameters:
name - The name.

getName

public java.lang.String getName()
Get the audio clip's name.

Returns:
The name.

toString

public java.lang.String toString()
Get a string representation of this object.

Returns:
The name of the audio clip.