public class SoundPlayer
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
private class |
SoundPlayer.SoundPlayerThread
Thread for playing sound files.
|
| Modifier and Type | Field and Description |
|---|---|
private static java.util.logging.Logger |
logger |
private javax.sound.sampled.Mixer |
mixer |
private SoundPlayer.SoundPlayerThread |
soundPlayerThread |
private int |
volume |
| Constructor and Description |
|---|
SoundPlayer(AudioMixerOption mixerOption,
PercentageOption volumeOption)
Creates a sound player.
|
| Modifier and Type | Method and Description |
|---|---|
static javax.sound.sampled.AudioInputStream |
getAudioInputStream(java.io.File file)
Gets an audio input stream given a file, hopefully containing audio data.
|
javax.sound.sampled.Mixer |
getMixer()
Gets the mixer.
|
int |
getVolume()
Gets the volume.
|
void |
playOnce(java.io.File file)
Plays a file once.
|
private void |
setMixer(AudioMixerOption.MixerWrapper mw) |
private void |
setVolume(int volume) |
void |
stop()
Stops the current sound.
|
private static final java.util.logging.Logger logger
private javax.sound.sampled.Mixer mixer
private int volume
private final SoundPlayer.SoundPlayerThread soundPlayerThread
public SoundPlayer(AudioMixerOption mixerOption, PercentageOption volumeOption)
mixerOption - The option for setting the mixer to use.volumeOption - The volume option to use when playing audio.public static javax.sound.sampled.AudioInputStream getAudioInputStream(java.io.File file)
throws java.lang.Exception
file - The File to test.AudioInputStream, or null on failure.Assorted - exceptions if the file does not contain valid audio.java.lang.Exceptionpublic javax.sound.sampled.Mixer getMixer()
private void setMixer(AudioMixerOption.MixerWrapper mw)
public int getVolume()
private void setVolume(int volume)
public void playOnce(java.io.File file)
file - The File to be played.public void stop()