public abstract class SoundPlayback
extends java.lang.Object
implements java.lang.Runnable
Modifier and Type | Class and Description |
---|---|
class |
SoundPlayback.VolumeControl
An object for controlling the volume of an
AudioPlayback . |
Modifier and Type | Field and Description |
---|---|
protected javax.sound.sampled.SourceDataLine |
line |
Modifier and Type | Method and Description |
---|---|
void |
addSoundPlaybackListener(SoundPlaybackListener listener)
Adds a
SoundPlaybackListener to this instance. |
void |
cancel()
Attempts to cancel the playback of this audio.
|
SoundPlayback.VolumeControl |
createVolumeControl() |
protected void |
finalize() |
protected void |
finish()
Finishes the playback.
|
float |
getMasterVolume()
Gets the current volume of this playback, considering all
VolumeControl objects created for it. |
SoundPlayback.VolumeControl |
getMasterVolumeControl() |
float |
getVolume()
Gets the current master volume of this playback.
|
boolean |
isPaused()
Determines if this playback is paused.
|
boolean |
isPlaying()
Determines if this playback has sound to play.
|
void |
pausePlayback()
Pauses this playback.
|
protected boolean |
play(Sound sound)
Plays a sound to this object's data line.
|
void |
removeSoundPlaybackListener(SoundPlaybackListener listener)
Removes a
SoundPlaybackListener from this instance. |
void |
resumePlayback()
Resumes this playback.
|
void |
setPaused(boolean paused)
Sets the paused state of this playback to the provided value.
|
void |
setVolume(float volume)
Sets the master volume of this playback.
|
void |
start()
Starts playing the audio.
|
public void start()
java.lang.IllegalStateException
- if the audio has already been startedprotected boolean play(Sound sound)
sound
- The sound to playprotected void finish()
public void addSoundPlaybackListener(SoundPlaybackListener listener)
SoundPlaybackListener
to this instance.listener
- The SoundPlaybackListener
to be added.public void removeSoundPlaybackListener(SoundPlaybackListener listener)
SoundPlaybackListener
from this instance.listener
- The SoundPlaybackListener
to be removed.public void setPaused(boolean paused)
paused
- Whether to pause or resume this playbackpublic void pausePlayback()
public void resumePlayback()
public boolean isPaused()
public boolean isPlaying()
true
, but it will
return false
if it has finished or it has been cancelled.public void cancel()
public float getMasterVolume()
VolumeControl
objects created for it.public float getVolume()
setVolume
,
though rounding errors may occur.public void setVolume(float volume)
volume
- The new volumepublic SoundPlayback.VolumeControl getMasterVolumeControl()
public SoundPlayback.VolumeControl createVolumeControl()
protected void finalize()
finalize
in class java.lang.Object