org.mars_sim.msp.ui.standard.sound
Class AudioPlayer

java.lang.Object
  extended by org.mars_sim.msp.ui.standard.sound.AudioPlayer
All Implemented Interfaces:
java.util.EventListener, javax.sound.midi.MetaEventListener, javax.sound.sampled.LineListener

public class AudioPlayer
extends java.lang.Object
implements javax.sound.sampled.LineListener, javax.sound.midi.MetaEventListener

A class to play sound files.


Constructor Summary
AudioPlayer()
           
 
Method Summary
 void cleanAudioPlayer()
           
 float getVolume()
          Gets the volume of the audio player.
 boolean isMute()
          Checks if the audio player is muted.
 void loop(java.lang.String filepath)
          Play the clip in a loop.
 void meta(javax.sound.midi.MetaMessage meta)
           
 void play(java.lang.String filepath)
          Play a clip once.
 void setMute(boolean mute)
          Sets if the audio player is mute or not.
 void setVolume(float volume)
          Sets the volume for the audio player.
 void startMidiSound(java.lang.String filepath, boolean loop)
          Play compressed sound (mp3 or ogg files) The sounds are not cached in this case.
 void startPlayCompressedSound(java.lang.String filepath, boolean loop)
          Play compressed sound (mp3 or ogg files) The sounds are not cached in this case.
 void startPlayWavSound(java.lang.String filepath, boolean loop)
          Play and cache sound of type wav.
 void stop()
          Stops the playing clip.
 void update(javax.sound.sampled.LineEvent event)
          LineListener interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AudioPlayer

public AudioPlayer()
Method Detail

startPlayWavSound

public void startPlayWavSound(java.lang.String filepath,
                              boolean loop)
Play and cache sound of type wav.

Parameters:
filepath - the file path to the sound
loop - Should the sound clip be looped?

startPlayCompressedSound

public void startPlayCompressedSound(java.lang.String filepath,
                                     boolean loop)
Play compressed sound (mp3 or ogg files) The sounds are not cached in this case.

Parameters:
filepath - filepath the file path to the sound
loop - Should the sound clip be looped?

startMidiSound

public void startMidiSound(java.lang.String filepath,
                           boolean loop)
Play compressed sound (mp3 or ogg files) The sounds are not cached in this case.

Parameters:
filepath - filepath the file path to the sound
loop - Should the sound clip be looped?

play

public void play(java.lang.String filepath)
Play a clip once.

Parameters:
filepath - the filepath to the sound file.

loop

public void loop(java.lang.String filepath)
Play the clip in a loop.

Parameters:
filepath - the filepath to the sound file.

stop

public void stop()
Stops the playing clip.


getVolume

public float getVolume()
Gets the volume of the audio player.

Returns:
volume (0.0 to 1.0)

setVolume

public void setVolume(float volume)
Sets the volume for the audio player.

Parameters:
volume - (0.0 quiet, .5 medium, 1.0 loud) (0.0 to 1.0 valid range)

isMute

public boolean isMute()
Checks if the audio player is muted.

Returns:
true if muted.

setMute

public void setMute(boolean mute)
Sets if the audio player is mute or not.

Parameters:
mute - is audio player mute?

update

public void update(javax.sound.sampled.LineEvent event)
LineListener interface. This method is called when an event occurs during the sound playing: end of sound...

Specified by:
update in interface javax.sound.sampled.LineListener

cleanAudioPlayer

public void cleanAudioPlayer()

meta

public void meta(javax.sound.midi.MetaMessage meta)
Specified by:
meta in interface javax.sound.midi.MetaEventListener