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


Java Clip.isActive方法代码示例

本文整理汇总了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();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:IsRunningHang.java

示例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();
}
 
开发者ID:CognitiveModeling,项目名称:BrainControl,代码行数:14,代码来源:Sounds.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:ChangingBuffer.java

示例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();
}
 
开发者ID:SEAL-UCLA,项目名称:Ref-Finder,代码行数:10,代码来源:Aurelizer.java

示例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);
}
 
开发者ID:SEAL-UCLA,项目名称:Ref-Finder,代码行数:10,代码来源:Aurelizer.java

示例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();
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:7,代码来源:Aurelizer.java

示例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);
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:7,代码来源:Aurelizer.java


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