public abstract class AbstractSCAudioClip extends java.lang.Object implements SCAudioClip
SCAudioClip
which is provided in
order to aid implementers by allowing them to extend
AbstractSCAudioClip and focus on the task of playing actual audio
once.Modifier and Type | Field and Description |
---|---|
protected AudioNotifierService |
audioNotifier
The AudioNotifierService which has initialized this instance.
|
protected java.lang.Object |
sync
The Object used for internal synchronization purposes which
arise because this instance does the actual playback of audio in a
separate thread.
|
protected java.lang.String |
uri
The String uri of the audio to be played by this instance.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractSCAudioClip(java.lang.String uri,
AudioNotifierService audioNotifier) |
Modifier and Type | Method and Description |
---|---|
protected void |
enterRunInPlayThread()
Notifies this instance that its execution in its background/separate
thread dedicated to the playback of this audio is about to start playing
this audio for the first time.
|
protected void |
enterRunOnceInPlayThread()
Notifies this instance that its execution in its background/separate
thread dedicated to the playback of this audio is about the start playing
this audio once.
|
protected void |
exitRunInPlayThread()
Notifies this instance that its execution in its background/separate
thread dedicated to the playback of this audio is about to stop playing
this audio once.
|
protected void |
exitRunOnceInPlayThread()
Notifies this instance that its execution in its background/separate
thread dedicated to the playback of this audio is about to stop playing
this audio.
|
int |
getLoopInterval()
Gets the interval of time in milliseconds between consecutive plays of
this audio.
|
protected void |
internalStop()
Stops this audio without setting the isLooping property in the case of
a looping audio.
|
boolean |
isInvalid()
Determines whether this instance is invalid.
|
boolean |
isLooping()
Determines whether this instance plays the audio it represents in a loop.
|
boolean |
isStarted()
Determines whether this audio is started i.e.
|
void |
play()
Starts playing this audio once only.
|
void |
play(int loopInterval,
java.util.concurrent.Callable<java.lang.Boolean> loopCondition)
Starts playing this audio.
|
protected abstract boolean |
runOnceInPlayThread()
Plays this audio once.
|
void |
setInvalid(boolean invalid)
Sets the indicator which determines whether this instance is invalid.
|
void |
setLooping(boolean looping)
Sets the indicator which determines whether this audio is to play in a
loop.
|
void |
setLoopInterval(int loopInterval)
Sets the interval of time in milliseconds between consecutive plays of
this audio in a loop.
|
void |
stop()
Stops playing this audio.
|
protected final AudioNotifierService audioNotifier
protected final java.lang.Object sync
The synchronization root is exposed to extenders in case they would like to, for example, get notified as soon as possible when this instance gets stopped.
protected final java.lang.String uri
protected AbstractSCAudioClip(java.lang.String uri, AudioNotifierService audioNotifier)
protected void enterRunInPlayThread()
protected void enterRunOnceInPlayThread()
protected void exitRunInPlayThread()
protected void exitRunOnceInPlayThread()
public int getLoopInterval()
protected void internalStop()
public boolean isInvalid()
setInvalid(boolean)
. The default value is false i.e.
this instance is valid by default.public boolean isLooping()
public boolean isStarted()
isStarted
in interface SCAudioClip
public void play()
SCAudioClip.play(int, Callable)
was invoked with a negative
loopInterval and/or null loopCondition.
Delegates to play(int, Callable)
with loopInterval
-1 and loopCondition null in order to conform
with the contract for the behavior of this method specified by the
interface SCAudioClip.play
in interface SCAudioClip
public void play(int loopInterval, java.util.concurrent.Callable<java.lang.Boolean> loopCondition)
play
in interface SCAudioClip
loopInterval
- the interval of time in milliseconds between
consecutive plays of this audio. If negative, this audio is played once
only and loopCondition is ignored.loopCondition
- a Callable which is called at the beginning
of each iteration of looped playback of this audio except the first one
to determine whether to continue the loop. If loopInterval is
negative or loopCondition is null, this audio is played
once only.protected abstract boolean runOnceInPlayThread()
public void setInvalid(boolean invalid)
isInvalid()
. The
default value is false i.e. this instance is valid by default.invalid
- true to mark this instance invalid or
false to mark it validpublic void setLooping(boolean looping)
play(int, Callable)
anyway.looping
- true to mark this instance that it should play
the audio it represents in a loop; otherwise, falsepublic void setLoopInterval(int loopInterval)
play(int, Callable)
is
null or its invocation fails.loopInterval
- the interval of time in milliseconds between
consecutive plays of this audio in a loop to be set on this instancepublic void stop()
stop
in interface SCAudioClip
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.