GTGE API

com.golden.gamedev.engine
Class BaseAudioRenderer

java.lang.Object
  extended by com.golden.gamedev.engine.BaseAudioRenderer
Direct Known Subclasses:
MidiRenderer, WaveRenderer

public abstract class BaseAudioRenderer
extends Object

A simple abstraction for playing audio sound.

BaseAudioRenderer must have one empty constructor.
For example :

    public class MP3AudioRenderer extends BaseAudioRenderer {

       public MP3Renderer() { // you should provide an empty constructor
          // init the class here
       }

    }
 

The empty constructor is used by BaseAudio to create a new renderer instance to play new sound using Class.newInstance().


Field Summary
static int END_OF_SOUND
          Audio renderer status indicates that the audio has finished played.
static int ERROR
          Audio renderer status indicates that the audio is failed to play.
static int PLAYING
          Audio renderer status indicates that the audio is currently playing.
protected  int status
          The audio renderer status.
static int STOPPED
          Audio renderer status indicates that the audio is currently stopped.
protected  float volume
          The audio sound volume.
 
Constructor Summary
BaseAudioRenderer()
          Creates new audio renderer.
 
Method Summary
 URL getAudioFile()
          Returns the audio resource URL associated with this audio renderer.
 int getStatus()
          Returns the audio renderer status.
 float getVolume()
          Returns audio volume.
abstract  boolean isAvailable()
          Returns true, if this audio renderer is available to use or false if this renderer is not available to use (failed to initialized).
 boolean isLoop()
          Returns whether the audio is playing continuosly or not.
 boolean isVolumeSupported()
          Returns whether setting audio volume is supported or not.
 void play()
          Restarts last or currently played audio.
 void play(URL audiofile)
          Stops currently played audio and begins playback of specified audio file.
protected abstract  void playSound(URL audiofile)
          Plays sound with specified audio file.
protected abstract  void replaySound(URL audiofile)
          Replays last played sound.
 void setLoop(boolean loop)
          Sets whether the sound should be playing continuously until stop method is called or not.
protected  void setSoundVolume(float volume)
          Sets audio sound volume.
 void setVolume(float volume)
          Sets audio volume in [0.0f - 1.0f].
 void stop()
          Stops currently played audio.
protected abstract  void stopSound()
          Stops any playing sound.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PLAYING

public static final int PLAYING
Audio renderer status indicates that the audio is currently playing.

See Also:
Constant Field Values

STOPPED

public static final int STOPPED
Audio renderer status indicates that the audio is currently stopped.

See Also:
Constant Field Values

END_OF_SOUND

public static final int END_OF_SOUND
Audio renderer status indicates that the audio has finished played.

See Also:
Constant Field Values

ERROR

public static final int ERROR
Audio renderer status indicates that the audio is failed to play.

See Also:
Constant Field Values

status

protected int status
The audio renderer status.

Use this to manage renderer's END_OF_SOUND status when the audio has finished played or ERROR status if the audio is failed to play in playSound(URL) method.


volume

protected float volume
The audio sound volume.

Constructor Detail

BaseAudioRenderer

public BaseAudioRenderer()
Creates new audio renderer.

See Also:
play(URL), setLoop(boolean)
Method Detail

playSound

protected abstract void playSound(URL audiofile)
Plays sound with specified audio file.


replaySound

protected abstract void replaySound(URL audiofile)
Replays last played sound.


stopSound

protected abstract void stopSound()
Stops any playing sound.


setSoundVolume

protected void setSoundVolume(float volume)
Sets audio sound volume.


play

public void play(URL audiofile)
Stops currently played audio and begins playback of specified audio file.

Parameters:
audiofile - the audio file to be played by this renderer.

play

public void play()
Restarts last or currently played audio.


stop

public void stop()
Stops currently played audio.


setLoop

public void setLoop(boolean loop)
Sets whether the sound should be playing continuously until stop method is called or not.

Note: the sound manager is the one that taking care the audio loop.

Parameters:
loop - true, the audio will be playing continously

isLoop

public boolean isLoop()
Returns whether the audio is playing continuosly or not.


setVolume

public void setVolume(float volume)
Sets audio volume in [0.0f - 1.0f].


getVolume

public float getVolume()
Returns audio volume.


isVolumeSupported

public boolean isVolumeSupported()
Returns whether setting audio volume is supported or not.


getAudioFile

public URL getAudioFile()
Returns the audio resource URL associated with this audio renderer.


getStatus

public int getStatus()
Returns the audio renderer status.


isAvailable

public abstract boolean isAvailable()
Returns true, if this audio renderer is available to use or false if this renderer is not available to use (failed to initialized).


GTGE API

Copyright © 2003-2005 Golden T Studios. All rights reserved. Use is subject to license terms.
GoldenStudios.or.id