javax.sound.sampled.Clip.isOpen()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中javax.sound.sampled.Clip.isOpen()方法的一些代码示例,展示了Clip.isOpen()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Clip.isOpen()方法的具体详情如下:
包路径:javax.sound.sampled.Clip
类名称:Clip
方法名:isOpen

Clip.isOpen介绍

暂无

代码示例

代码示例来源:origin: de.dfki.mary/marytts-client

private void playAudio() {
  assert clip != null && clip.isOpen();
  clip.start();
}

代码示例来源:origin: stackoverflow.com

protected synchronized void play(Clip clip){

  try{            
    if(clip.isOpen()){
      System.out.println("clip is opened...");
      clip.start();
      clip.setMicrosecondPosition(0);     //like rewinding the clip
       try {Thread.sleep(10);}
       catch (Exception e) {}
    }
    System.out.println("shooting");
  }
  catch(Exception e){e.printStackTrace();}
}

代码示例来源:origin: stackoverflow.com

static String randomName = "TreasureQuest";
public static Clip clip = null;
public static void playSound(String name) throws Exception{
  if (clip != null && clip.isOpen()) clip.close();
    AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File("music/" + name + ".wav").getAbsoluteFile());
    clip = AudioSystem.getClip();

    clip.open(audioInputStream);
    FloatControl gainControl = 
        (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
      gainControl.setValue(0f);

    System.out.println(clip.getFrameLength() + " | " + clip.getFramePosition());
    clip.start();

}

代码示例来源:origin: de.dfki.mary/marytts-client

currentAudio = AudioSystem.getAudioInputStream(new ByteArrayInputStream(bytes));
if (currentAudio == null && (clip == null || !clip.isOpen())) {
  bPlay.setEnabled(false);
  throw new Exception("No audio data to play (did synthesis succeed?)");
  if (clip != null && clip.isOpen())
    closeClip();

代码示例来源:origin: stackoverflow.com

if(clip.isOpen()) clip.close();

相关文章