本文整理汇总了Java中javax.sound.sampled.Clip.LOOP_CONTINUOUSLY属性的典型用法代码示例。如果您正苦于以下问题:Java Clip.LOOP_CONTINUOUSLY属性的具体用法?Java Clip.LOOP_CONTINUOUSLY怎么用?Java Clip.LOOP_CONTINUOUSLY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.sound.sampled.Clip
的用法示例。
在下文中一共展示了Clip.LOOP_CONTINUOUSLY属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resume
@Override
public void resume() {
if (!clip.isRunning() && getState() == Playback.State.PAUSED) {
logger.info("Resuming playback of \"" + audio.getFileName()
+ "\" instance " + instanceID);
long loopsPlayed = clip.getMicrosecondPosition()
/ clip.getMicrosecondLength();
int loopsToGo = (numLoops - (int) loopsPlayed);
if (loopsToGo <= 0 && !loopContinuously) {
loopsToGo = 1;
} else if (loopContinuously) {
loopsToGo = Clip.LOOP_CONTINUOUSLY;
}
state = Playback.State.PLAYING;
clip.loop(loopsToGo);
}
}
示例2: start
/**
* Start playback of this {@code PreloadedPlayback}.
*
* @param volume
* The desired volume.
* @param numLoops
* The number of times the audio data will be played in
* succession.
* @param exec
* Manages the thread that this {@code PreloadedPlayback} runs
* in.
*/
protected void start(double volume, int numLoops, final ExecutorService exec) {
this.numLoops = numLoops - 1; // By definition, loop(0) plays once.
if (numLoops < 0) {
this.numLoops = Clip.LOOP_CONTINUOUSLY; // (-1)
loopContinuously = true;
}
setVolume(volume);
try {
exec.execute(this);
} catch (RejectedExecutionException e) {
logger.warning("A play request was received "
+ "but the system is shutting down."
+ " Cannot perform the play request.");
}
}