org.hermit.android.sound
Class Player

java.lang.Object
  extended by org.hermit.android.sound.Player

public class Player
extends java.lang.Object

Main sound effects player class.


Constructor Summary
Player(Context context)
          Create a sound effect player that can handle 3 streams at once.
Player(Context context, int streams)
          Create a sound effect player.
 
Method Summary
 Effect addEffect(int sound)
          Add a sound effect to this player.
 Effect addEffect(int sound, float vol)
          Add a sound effect to this player.
 int play(Effect effect)
          Play the given sound effect.
 int play(Effect effect, float rvol, boolean loop)
          Play the given sound effect.
 void setGain(float gain)
          Set the overall gain for sounds.
 void stop(int id)
          Stop the given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Player

public Player(Context context)
Create a sound effect player that can handle 3 streams at once.

Parameters:
context - Application context we're running in.

Player

public Player(Context context,
              int streams)
Create a sound effect player.

Parameters:
context - Application context we're running in.
streams - Maximum number of sound streams to play simultaneously.
Method Detail

addEffect

public Effect addEffect(int sound)
Add a sound effect to this player.

Parameters:
sound - Resource ID of the sound sample for this effect.
Returns:
An Effect object representing the new effect. Use this object to actually play the sound.

addEffect

public Effect addEffect(int sound,
                        float vol)
Add a sound effect to this player.

Parameters:
sound - Resource ID of the sound sample for this effect.
vol - Base volume for this effect.
Returns:
An Effect object representing the new effect. Use this object to actually play the sound.

setGain

public void setGain(float gain)
Set the overall gain for sounds.

Parameters:
gain - Desired gain. 1 = normal; 0 means don't play sounds.

play

public int play(Effect effect)
Play the given sound effect.

Parameters:
effect - Sound effect to play.
Returns:
The ID of the stream which is playing the sound. Zero if it's not playing.

play

public int play(Effect effect,
                float rvol,
                boolean loop)
Play the given sound effect. The sound won't be played if the volume would be zero or less.

Parameters:
effect - Sound effect to play.
rvol - Relative volume for this sound, 0 - 1.
loop - If true, loop the sound forever.
Returns:
The ID of the stream which is playing the sound. Zero if it's not playing; this includes if sounds are disabled, or if the volume is zero.

stop

public void stop(int id)
Stop the given stream.

Parameters:
id - Stream ID to stop.