de.rico.adventure.actions.custom
Class PlayMP3

java.lang.Object
  extended by de.rico.adventure.actions.AbstractAction
      extended by de.rico.adventure.actions.custom.PlayMP3

public class PlayMP3
extends AbstractAction

This game action can be used to play an mp3 sound file either in a queued or a concurrent way.

Author:
Frank Bruns

Constructor Summary
PlayMP3(java.lang.String path, boolean loop, boolean concurrent)
          Game action that plays an mp3 file queued or concurrently.
 
Method Summary
 void draw(javax.media.opengl.GL gl)
          This method renders the game action, if needed.
 void finishUp()
          Implementations of this method hold code that needs to be called before the game action can be removed from the queue (prematurely) without causing side effects.
 void stop()
          This is a method to stop the playback of the sound in the special case that you looped the sound and played it concurrently.
 void update(long elapsedTime)
          This method updates the game action
 
Methods inherited from class de.rico.adventure.actions.AbstractAction
getEntity
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlayMP3

public PlayMP3(java.lang.String path,
               boolean loop,
               boolean concurrent)
Game action that plays an mp3 file queued or concurrently. Note that concurrently played sound file won't stop playing when the game action was removed from the action queue.

Note: In some rare cases you would like to start a looped sound in a queued manner on the game action scheduler. But you really have to be cautious with looping the sound. If you loop the sound there are two scenarios to consider:
  1. If you loop the sound and play it concurrently there is no easy way to stop the sound again. You will have to get a hold on this game action's object and call the stop() method to stop it.
  2. If you loop the sound and don't play it concurrently the sound will block the game action queue forever and ever. So to stop such a sound you will have to remove the action from the queue manually, by calling its removeFirst() method

Parameters:
path - path to mp3 sound file
loop - loop the sound? --> true=yes, false=no
concurrent - play concurrently --> true=yes, false=no
Method Detail

update

public void update(long elapsedTime)
Description copied from class: AbstractAction
This method updates the game action

Specified by:
update in class AbstractAction
Parameters:
elapsedTime - time between two frames

draw

public void draw(javax.media.opengl.GL gl)
Description copied from class: AbstractAction
This method renders the game action, if needed.

Specified by:
draw in class AbstractAction

finishUp

public void finishUp()
Description copied from class: AbstractAction
Implementations of this method hold code that needs to be called before the game action can be removed from the queue (prematurely) without causing side effects.

Specified by:
finishUp in class AbstractAction

stop

public void stop()
This is a method to stop the playback of the sound in the special case that you looped the sound and played it concurrently. See the javadoc comments on that case at the constructor. The method will have no effect in any other case.