|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.uiuc.cs397rhc.sound.SoundFilePlayer
SoundFilePlayer loops over a given sound file while providing fading
functionality.
| Field Summary | |
|---|---|
static int |
DEFAULT_LOOP
Default looping mode for playback. |
| Fields inherited from interface edu.uiuc.cs397rhc.sound.Fadeable |
|---|
DEFAULT_FADE_DURATION, DEFAULT_SLEEP_INTERVAL |
| Constructor Summary | |
|---|---|
SoundFilePlayer(java.lang.String filename)
Creates a SoundFilePlayer for the file with the given file name. |
|
SoundFilePlayer(java.lang.String filename,
int loop)
Creates a SoundFilePlayer for the file with the given file name. |
|
| Method Summary | |
|---|---|
void |
fade(double targetPercent)
Fade from the current multiplier to the target multiplier, over the default duration and with the default interval between volume changes. |
void |
fade(double targetPercent,
long duration)
Fade from the current multiplier to the target mulitplier, over the given duration and with the default interval between volume changes. |
void |
fade(double targetPercent,
long duration,
int steps)
Fade from the current multiplier to the target multiplier, over the given duration and in the given number of steps. |
double |
getFadeMultiplier()
Returns the current fade multiplier. |
java.io.File |
getFile()
The File being played. |
int |
getLoopCount()
The number of times the file should be looped, or -1 for infinite. |
protected double |
getVolumeMultiplier()
Convenience method that returns a single multiplier by which the volume should be multiplied to account for both fading and equalizing. |
double |
getVolumePercentage()
Gets the independent volume percentage of the object. |
boolean |
isFading()
Whether a fade is in progress |
boolean |
isPlaying()
Whether the file should be currently playing. |
protected abstract 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 |
setFadeMultiplier(double multiplier)
Sets the current fade multiplier, thereby also stopping any fading. |
void |
setVolumePercentage(double percent)
Sets the volume percentage of the object independently of other volume manipulations, such as fading. |
void |
start()
Starts playing the file in a new thread. |
void |
stop()
Stops playing the file. |
abstract void |
updateVolume()
Update the volume to reflect the current fade multiplier. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_LOOP
| Constructor Detail |
|---|
public SoundFilePlayer(java.lang.String filename,
int loop)
SoundFilePlayer for the file with the given file name.
filename - the name of the MP3 fileloop - the number of times to loop, or -1 for infinitepublic SoundFilePlayer(java.lang.String filename)
SoundFilePlayer for the file with the given file name.
filename - the name of the MP3 file| Method Detail |
|---|
public boolean isPlaying()
play() methods.
true if playing, false otherwisepublic int getLoopCount()
public java.io.File getFile()
public double getVolumePercentage()
Equalizable
getVolumePercentage in interface Equalizablepublic void setVolumePercentage(double percent)
Equalizable
setVolumePercentage in interface Equalizablepercent - the new volume percentagepublic double getFadeMultiplier()
Fadeable
getFadeMultiplier in interface Fadeablepublic void setFadeMultiplier(double multiplier)
Fadeable
setFadeMultiplier in interface Fadeablemultiplier - the new fade multiplierpublic boolean isFading()
Fadeable
isFading in interface Fadeabletrue if a fade is in progress, false
otherwisepublic void fade(double targetPercent)
Fadeable
fade in interface FadeabletargetPercent - the target volume percentage after the fade
public void fade(double targetPercent,
long duration)
Fadeable
fade in interface FadeabletargetPercent - the target volume percentage after the fadeduration - the duration of the fade in milliseconds
public void fade(double targetPercent,
long duration,
int steps)
Fadeable
fade in interface FadeabletargetPercent - the target volume percentage after the fadeduration - the duration of the fade in millisecondssteps - the number of volume changes during the fadeprotected double getVolumeMultiplier()
public abstract void updateVolume()
Fadeable
updateVolume in interface Fadeableprotected abstract void play()
isPlaying() returns
false or until the file is done looping, in which case
stop() should be called.
public void start()
public void stop()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||