ewe.fx
Class SoundClip

java.lang.Object
  extended byewe.fx.SoundClip

public class SoundClip
extends Object

SoundClip is a sound clip. The sound clip is loaded and then played when requested. Support will soon be added for looping the sound and stopping the sound.

 SoundClip s = new SoundClip("sound.wav");
 s.play(PLAY_ASYNC);
 


Field Summary
 byte[] data
           
 int fixedData
           
static int PLAY_ASYNC
          Play asynchronously
static int PLAY_LOOP
          Loop the sound until stop() is called
static int PLAY_NOSTOP
          Don't stop any currently playing sound
static int PLAY_SYNC
          Play synchronously (default)
 int playStatus
           
 
Constructor Summary
SoundClip(byte[] waveData)
           
SoundClip(Class requestor, String path)
          Loads and constructs a sound clip from a resource.
SoundClip(String path)
          Loads and constructs a sound clip from a resource.
 
Method Summary
 void finalize()
          This method (when overriden), will be called when the VM determines that the Object can be garbage collected.
 void free()
           
 boolean play(int options)
          Plays the sound clip.
 boolean stop()
          Stop the currently playing sound.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, toString
 

Field Detail

data

public byte[] data

playStatus

public int playStatus

fixedData

public int fixedData

PLAY_SYNC

public static final int PLAY_SYNC
Play synchronously (default)

See Also:
Constant Field Values

PLAY_ASYNC

public static final int PLAY_ASYNC
Play asynchronously

See Also:
Constant Field Values

PLAY_LOOP

public static final int PLAY_LOOP
Loop the sound until stop() is called

See Also:
Constant Field Values

PLAY_NOSTOP

public static final int PLAY_NOSTOP
Don't stop any currently playing sound

See Also:
Constant Field Values
Constructor Detail

SoundClip

public SoundClip(Class requestor,
                 String path)
Loads and constructs a sound clip from a resource. Throws an illegal argument exception if the clip is not found.


SoundClip

public SoundClip(String path)
Loads and constructs a sound clip from a resource. Throws an illegal argument exception if the clip is not found.


SoundClip

public SoundClip(byte[] waveData)
Method Detail

play

public boolean play(int options)
Plays the sound clip. Returns true if the sound starts playing and false otherwise.

Parameters:
options - Can be one of the PLAY_XXXX options.
Returns:
true if the sound starts playing and false otherwise.

stop

public boolean stop()
Stop the currently playing sound.

Returns:
true if successful.

free

public void free()

finalize

public void finalize()
Description copied from class: Object
This method (when overriden), will be called when the VM determines that the Object can be garbage collected. Any action can be taken by the finalize() method, including making the Object available to other Threads (which would stop the garbage collection of the Object).

The finalize() method of a Class is only called if it overrides finalize() - the finalize() method java.lang.Object is never called by the Ewe VM.

Note that under a native Ewe VM, the call to finalize() will be synchronized with the Ewe library, but under a Java VM, the finalize() method may be called by a separate Thread that is not synchronized with the Ewe library. To ensure that the execution of the finalize() method is sychronized with the Ewe library your finalize() method should look like this:

 protected void finalize()
 {
   synchronized(ewe.sys.Vm.getSyncObject()){
   //
   // Put your finalize() code here.
   //
   }
 }
 
Under Ewe the synchronized keyword is silently ignored.

Overrides:
finalize in class Object