public class Sound
extends java.lang.Object
Constructor and Description |
---|
Sound(java.lang.String deviceName,
java.lang.String filename)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the sound.
|
void |
drain()
Waits for the sound to stop playing, then returns.
|
void |
finalize() |
double |
getDuration()
Returns the duration of the clip in seconds down to the microsecond.
|
java.lang.String |
getErrorMessage()
Returns the error message.
|
long |
getLastTimePlayed()
Returns the system time of the last time this clip was played.
|
static double |
getMasterVolume()
Returns the master volume percentage
|
double |
getVolume()
Get the volume for this clip as a percentage of the volume range.
|
boolean |
isPlaying()
Returns true if clip is currently playing
|
static void |
loadMixers() |
void |
loop(int count)
Plays the sound, count, times in the background.
|
static void |
main(java.lang.String[] args) |
void |
play()
Starts the sound playing in the background.
|
void |
setBalance(double percentage)
Sets the balance position as a percentage of left to right.
|
static void |
setMasterVolume(double percentage)
Sets the master volume percentage.
|
void |
setMinTimeBetweenPlays(long milliseconds)
Sets the minimum time between plays in milliseconds
|
void |
setVolume(double percentage)
Set the volume for this clip as a percentage of the volume range.
|
void |
stop()
Stops the currently playing sound.
|
public Sound(java.lang.String deviceName, java.lang.String filename)
deviceName
- The Sound device name.filename
- The path to the audio file to play. Can be a resource in the classpath.public java.lang.String getErrorMessage()
public double getDuration()
public long getLastTimePlayed()
public static double getMasterVolume()
public static void setMasterVolume(double percentage)
percentage
- The percentage in the range of 0.0 to 1.0 or 0.0 to 100.0public double getVolume()
public void setVolume(double percentage)
percentage
- The percentage in the range of 0.0 to 1.0 or 0.0 to 100.0public void setBalance(double percentage)
percentage
- The balance position as a percentage between 0.0 to 100.0.public void play()
public boolean isPlaying()
public void setMinTimeBetweenPlays(long milliseconds)
milliseconds
- Number of milliseconds to wait. Defaults to zero.public void loop(int count)
count
- The number of times to play the sound.public void drain()
public void stop()
public void close()
public void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public static void loadMixers()
public static void main(java.lang.String[] args)