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

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

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

Clip.isRunning介绍

暂无

代码示例

代码示例来源:origin: redomar/JavaGame

public void stop() {
  if (clip.isRunning()) clip.stop();
  active = false;
}

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

String resPath="res/" ;
   File f=new File(resPath);
   File[] result=f.listFiles();
   String[] filePath=new String[result.length];
   for(int i=0;i<result.length;i++){
     filePath[i]=resPath+result[i].getName();
   }
   for(String audioPath:filePath) {
     AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File(audioPath).getAbsoluteFile());
     Clip clip = AudioSystem.getClip();
     clip.open(audioInputStream);
     clip.start();
     while (!clip.isRunning())
       Thread.sleep(10);
     while (clip.isRunning())
       Thread.sleep(10);
     clip.close();
   }

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

File soundFile = new File("/home/usr/Desktop/d.wav");
AudioInputStream soundIn = AudioSystem.getAudioInputStream(soundFile);
AudioFormat format = soundIn.getFormat();
DataLine.Info info = new DataLine.Info(Clip.class, format);
Clip clip = (Clip)AudioSystem.getLine(info);
clip.open(soundIn);
clip.start();
while(clip.isRunning())
{
  Thread.yield();
}

代码示例来源:origin: us.ihmc/ihmc-java-toolkit

/**
* Play a clip once. Will do nothing if clip is already playing.
*/
public static void playSoundOnce(Clip clip)
{      
 if (clip == null || clip.isRunning())
   return;
 
 clip.setFramePosition(0);
 clip.start();
}

代码示例来源:origin: us.ihmc/IHMCJavaToolkit

/**
* Play a clip once. Will do nothing if clip is already playing.
*/
public static void playSoundOnce(Clip clip)
{      
 if (clip == null || clip.isRunning())
   return;
 
 clip.setFramePosition(0);
 clip.start();
}

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

return clip != null && clip.isRunning();
if (clip != null && !clip.isRunning()) {
  clip.start();
if (clip != null && clip.isRunning()) {
  clip.stop();

代码示例来源:origin: org.apache.ant/ant-jmf

private void playClip(Clip clip, int loops) {
  clip.loop(loops);
  do {
    try {
      long timeLeft =
        (clip.getMicrosecondLength() - clip.getMicrosecondPosition())
        / 1000;
      if (timeLeft > 0) {
        Thread.sleep(timeLeft);
      }
    } catch (InterruptedException e) {
      break;
    }
  } while (clip.isRunning());
  if (clip.isRunning()) {
    clip.stop();
  }
}

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

Clip clip4 = null; // Make this a member variable.
...
if (message.equals("rock1")) {
 AudioInputStream inputStream = AudioSystem.getAudioInputStream(new File("D:/Andrd/Music/TheAll-AmericanRejects-Swing,Swing.wav"));
 clip4 = AudioSystem.getClip();
 clip4.open(inputStream);
 clip4.start();
} else if (message.equals("stop") && clip4 != null && clip4.isRunning())
 clip4.stop();
}

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

class TestFramePosition {
  public static void main(String[] a) throws Exception {
    File file = new File(a.length > 0 ? a[0] : "path/to/file.extension");
    AudioInputStream ais = AudioSystem.getAudioInputStream(file);
    final Clip clip = AudioSystem.getClip();

    clip.open(ais);
    clip.start();

    new Thread(new Runnable() {
      @Override
      public void run() {
        while(clip.isRunning()) {
          try {
            System.out.println(clip.getMicrosecondPosition());
            Thread.sleep(1000 / 10);
          } catch(InterruptedException ignored) {}
        }
      }
    }).start();

    System.in.read();
    System.exit(0);
  }
}

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

clip.open(audio);
if (!clip.isRunning()) {
  clip.start();

代码示例来源:origin: us.ihmc/ihmc-java-toolkit

/**
* Used for playing a clip over and over again. Just load the same 
* clip 20 times or so into an array and call this to play it over
* and over again on top of itself.
*/
public static void playFirstNotRunningClip(Clip[] clips)
{
 for (int i = 0; i < clips.length; i++)
 {
   if (clips[i].isRunning())
   {
    continue;
   }
   else
   {
    clips[i].setFramePosition(0);
    clips[i].start();
    return;
   }
 }
}

代码示例来源:origin: us.ihmc/IHMCJavaToolkit

/**
* Used for playing a clip over and over again. Just load the same 
* clip 20 times or so into an array and call this to play it over
* and over again on top of itself.
*/
public static void playFirstNotRunningClip(Clip[] clips)
{
 for (int i = 0; i < clips.length; i++)
 {
   if (clips[i].isRunning())
   {
    continue;
   }
   else
   {
    clips[i].setFramePosition(0);
    clips[i].start();
    return;
   }
 }
}

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

public void playClip( Clip clip )
{
  if( clip.isRunning() )
  {
    clip.stop();
  }
  clip.setFramePosition( 0 );
  clip.start();
}

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

public void playClip( Clip clip )
{
  if( clip.isRunning() ) clip.stop();
      clip.setFramePosition( 0 );
  clip.start();
}

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

if (clip.isRunning()) {
  clip.stop();

代码示例来源:origin: com.github.nifty-gui/nifty-pauls-soundsystem

if( clip != null )
  boolean rePlay = clip.isRunning();
  clip.stop();
  clip.setFramePosition(0);

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

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

代码示例来源:origin: UNIVALI-LITE/Portugol-Studio

public void inicia(boolean repetir)
{
  if (clip == null)
  {
    return;
  }
  if (clip.isRunning())
  {
    clip.stop();
  }            
  clip.setFramePosition(0);
  if(clipTime>0)
  {
    clip.setMicrosecondPosition(clipTime);
    clipTime=0;
    clip.start();
  }
  if (!repetir)
  {
    clip.loop(0);
  }
  else
  {
    clip.loop(Clip.LOOP_CONTINUOUSLY);
  }
}

相关文章