本文整理汇总了Java中javax.sound.sampled.Clip.isActive方法的典型用法代码示例。如果您正苦于以下问题:Java Clip.isActive方法的具体用法?Java Clip.isActive怎么用?Java Clip.isActive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sound.sampled.Clip
的用法示例。
在下文中一共展示了Clip.isActive方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: play
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public static void play(Type type)
{
Clip[] cliparr = clips.get(type);
Clip clip = cliparr[type.current];
if(clip.isActive())
{
clip.flush();
clip.stop();
}
clip.setFramePosition(0);
clip.start();
}
示例3: doMixerClip
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
private static boolean doMixerClip(Mixer mixer, AudioFormat format) {
if (mixer==null) return false;
try {
System.out.println("Trying mixer "+mixer+":");
DataLine.Info info = new DataLine.Info(
Clip.class,
format,
(int) samplerate);
Clip clip = (Clip) mixer.getLine(info);
System.out.println(" - got clip: "+clip);
System.out.println(" - open with format "+format);
clip.open(format, buffer, 0, buffer.length);
System.out.println(" - playing...");
clip.start();
System.out.println(" - waiting while it's active...");
while (clip.isActive())
Thread.sleep(100);
System.out.println(" - waiting 100millis");
Thread.sleep(100);
System.out.println(" - drain1");
clip.drain();
System.out.println(" - drain2");
clip.drain();
System.out.println(" - stop");
clip.stop();
System.out.println(" - close");
clip.close();
System.out.println(" - closed");
} catch (Throwable t) {
System.out.println(" - Caught exception. Not failed.");
System.out.println(" - "+t.toString());
return false;
}
return true;
}
示例4: enter
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public synchronized void enter(String eventName)
{
Clip clip = (Clip)this.clips.get(eventName);
if (clip.isActive()) {
clip.stop();
}
clip.setFramePosition(0);
clip.start();
}
示例5: enter_loop
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public synchronized void enter_loop(String eventName)
{
Clip clip = (Clip)this.clips.get(eventName);
if (clip.isActive()) {
clip.stop();
}
clip.setFramePosition(0);
clip.loop(-1);
}
示例6: enter
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public synchronized void enter(String eventName) {
Clip clip = (Clip)clips.get(eventName);
if (clip.isActive()) clip.stop();
clip.setFramePosition(0);
clip.start();
}
示例7: enter_loop
import javax.sound.sampled.Clip; //导入方法依赖的package包/类
public synchronized void enter_loop(String eventName) {
Clip clip = (Clip)clips.get(eventName);
if (clip.isActive()) clip.stop();
clip.setFramePosition(0);
clip.loop(Clip.LOOP_CONTINUOUSLY);
}