本文整理汇总了Java中javax.sound.sampled.Clip.isRunning方法的典型用法代码示例。如果您正苦于以下问题:Java Clip.isRunning方法的具体用法?Java Clip.isRunning怎么用?Java Clip.isRunning使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sound.sampled.Clip
的用法示例。
在下文中一共展示了Clip.isRunning方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
private static void test(final AudioFormat format, final byte[] data)
throws Exception {
final Line.Info info = new DataLine.Info(Clip.class, format);
final Clip clip = (Clip) AudioSystem.getLine(info);
go = new CountDownLatch(1);
clip.addLineListener(event -> {
if (event.getType().equals(LineEvent.Type.START)) {
go.countDown();
}
});
clip.open(format, data, 0, data.length);
clip.start();
go.await();
while (clip.isRunning()) {
// This loop should not hang
}
while (clip.isActive()) {
// This loop should not hang
}
clip.close();
}
示例2: run
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
@Override
public void run() {
AudioInputStream audioInputStream;
try {
audioInputStream = AudioSystem.getAudioInputStream(clickUrl);
DataLine.Info info = new DataLine.Info(Clip.class, audioInputStream.getFormat());
Clip clip = (Clip) AudioSystem.getLine(info);
if (clip.isRunning()) {
clip.close();
}
clip.open(audioInputStream);
clip.start();
} catch (Exception e) {
e.printStackTrace();
Main.myErr(Arrays.toString(e.getStackTrace()).replace(",", "\n"));
}
}
示例3: play
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public static void play(String s, int i) {
if(mute) return;
Clip c = clips.get(s);
if(c == null) return;
if(c.isRunning()) c.stop();
c.setFramePosition(i);
while(!c.isRunning()) c.start();
}