当前位置: 首页>>代码示例>>Java>>正文


Java Clip.LOOP_CONTINUOUSLY属性代码示例

本文整理汇总了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);
	}
}
 
开发者ID:cmholton,项目名称:QwickSound,代码行数:17,代码来源:PreloadedPlayback.java

示例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.");
	}
}
 
开发者ID:cmholton,项目名称:QwickSound,代码行数:27,代码来源:PreloadedPlayback.java


注:本文中的javax.sound.sampled.Clip.LOOP_CONTINUOUSLY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。