talx x1.0.5

component
Class AudioPlayer

java.lang.Object
  extended bycomponent.AudioPlayer

public class AudioPlayer
extends java.lang.Object

This class is a wrapper for the Java Media Framework tools that can play AUDIO. It takes filename, and provides methods for loading, playing, stopping, etc.

Version:
Sept. 2004
Author:
Jason Prideaux

Constructor Summary
AudioPlayer(java.lang.String filename)
          This constructor just sets the filename of the audio.
 
Method Summary
 void clear()
          This method will stop the media, and clear it from memory.
 javax.media.Time getDuration()
          This method returns the duration of the preloaded media.
 java.lang.String getFilename()
          This method returns the filename of media
 double getTimeRemaining()
          This method returns the time left till it finished in seconds.
 boolean isPlaying()
          This method checks if the media is still playing.
 boolean isReady()
          This method checks if the media is loaded and ready to play.
 void preload()
          This method will preload the media so that it is ready to play.
 void setFilename(java.lang.String f)
          This method sets the filename of media.
 void setRate(float f)
          This method sets the rate/speed of the media 1.0 is default.
 void setStopTime(javax.media.Time stop)
          This method can set the Time at which the media should stop playing.
 void start()
          This method will start the media.
 void stop()
          This method will stop the media, but will not clear it from memory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AudioPlayer

public AudioPlayer(java.lang.String filename)
This constructor just sets the filename of the audio. Some else should call the preload or start methods in a thread, since this class can hang while loading.

Parameters:
filename - The audio clip
Method Detail

isPlaying

public boolean isPlaying()
This method checks if the media is still playing. It will for at least 100 milliseconds while checking, so it is best to call while in a thread.

Returns:
boolean true if media is playing

start

public void start()
This method will start the media. It will first try to preload the media if it hasn't been loaded yet. This method may hang while loading, so it is best to call from a thread.


setRate

public void setRate(float f)
This method sets the rate/speed of the media 1.0 is default.


getDuration

public javax.media.Time getDuration()
This method returns the duration of the preloaded media.


getTimeRemaining

public double getTimeRemaining()
This method returns the time left till it finished in seconds.


setStopTime

public void setStopTime(javax.media.Time stop)
This method can set the Time at which the media should stop playing.


stop

public void stop()
This method will stop the media, but will not clear it from memory. This allows the clip to be quickly restarted.


isReady

public boolean isReady()
This method checks if the media is loaded and ready to play.

Returns:
boolean true if it is ready.

clear

public void clear()
This method will stop the media, and clear it from memory.


preload

public void preload()
This method will preload the media so that it is ready to play. This method may hang while loading, so it is best to call from a thread.


getFilename

public java.lang.String getFilename()
This method returns the filename of media


setFilename

public void setFilename(java.lang.String f)
This method sets the filename of media.


talx x1.0.5

© 2001-2005 University of Oregon.
Eugene OR 97403, U.S.A. All Rights Reserved.