edu.uiuc.cs397rhc.sound
Class MP3Player

java.lang.Object
  extended by edu.uiuc.cs397rhc.sound.SoundFilePlayer
      extended by edu.uiuc.cs397rhc.sound.MP3Player
All Implemented Interfaces:
Equalizable, Fadeable

public class MP3Player
extends SoundFilePlayer

MP3Player loops over a given MP3 file while providing fading functionality.

Author:
Pedro DeRose

Field Summary
 
Fields inherited from class edu.uiuc.cs397rhc.sound.SoundFilePlayer
DEFAULT_LOOP
 
Fields inherited from interface edu.uiuc.cs397rhc.sound.Fadeable
DEFAULT_FADE_DURATION, DEFAULT_SLEEP_INTERVAL
 
Constructor Summary
MP3Player(java.lang.String filename)
          Creates an MP3Player for the file with the given file name.
MP3Player(java.lang.String filename, int loop)
          Creates an MP3Player for the file with the given file name.
 
Method Summary
static void main(java.lang.String[] args)
           
protected  void play()
          Plays the file in a loop until isPlaying() returns false or until the file is done looping, in which case stop() should be called.
 void updateVolume()
          Update the volume to reflect the current fade multiplier.
 
Methods inherited from class edu.uiuc.cs397rhc.sound.SoundFilePlayer
fade, fade, fade, getFadeMultiplier, getFile, getLoopCount, getVolumeMultiplier, getVolumePercentage, isFading, isPlaying, setFadeMultiplier, setVolumePercentage, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MP3Player

public MP3Player(java.lang.String filename)
Creates an MP3Player for the file with the given file name.

Parameters:
filename - the name of the MP3 file

MP3Player

public MP3Player(java.lang.String filename,
                 int loop)
Creates an MP3Player for the file with the given file name.

Parameters:
filename - the name of the MP3 file
loop - the number of times to loop, -1 for infinite
Method Detail

updateVolume

public void updateVolume()
Description copied from interface: Fadeable
Update the volume to reflect the current fade multiplier. This should generally not have to be called by a client class, and is used primarily by the FadeHelper to notify a volume change during a fade.

Specified by:
updateVolume in interface Fadeable
Specified by:
updateVolume in class SoundFilePlayer

play

protected void play()
Description copied from class: SoundFilePlayer
Plays the file in a loop until isPlaying() returns false or until the file is done looping, in which case stop() should be called.

Specified by:
play in class SoundFilePlayer

main

public static void main(java.lang.String[] args)