public abstract class SoundPlayback
extends java.lang.Object
implements java.lang.Runnable
SoundPlayback
class is a wrapper SourceDataLine
on which a Sound
playback can be carried out.play(Sound)
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.
|
protected void |
finalize() |
float |
getMasterVolume()
Gets the current volume of this playback, considering all
VolumeControl objects created for it. |
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.
|
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 startedpublic 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 volume.protected void finalize()
finalize
in class java.lang.Object