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

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

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

Clip.setFramePosition介绍

暂无

代码示例

代码示例来源:origin: marytts/marytts

public void actionPerformed(ActionEvent e) {
    synchronized (clip) {
      if (clip.isActive()) {
        System.err.println("Stopping clip.");
        clip.stop();
      } else {
        System.err.println("Rewinding clip.");
        if (Double.isNaN(positionCursor.x)) { // no cursor, play from start
          clip.setFramePosition(0);
        } else { // play from cursor position
          clip.setFramePosition(X2indexX(positionCursor.x));
        }
        if (!Double.isNaN(rangeCursor.x)) { // range set?
          System.err.println("Setting timer task");
          int endFrame = X2indexX(rangeCursor.x);
          timer.schedule(new ClipObserver(clip, endFrame), 50, 50);
        }
        System.err.println("Starting clip.");
        clip.start();
      }
    }
  }
});

代码示例来源:origin: marytts/marytts

public void actionPerformed(ActionEvent e) {
    synchronized (clip) {
      if (clip.isActive()) {
        System.err.println("Stopping clip.");
        clip.stop();
      } else {
        System.err.println("Rewinding clip.");
        if (Double.isNaN(positionCursor.x)) { // no cursor, play from start
          clip.setFramePosition(0);
        } else { // play from cursor position
          clip.setFramePosition(X2indexX(positionCursor.x));
        }
        if (!Double.isNaN(rangeCursor.x)) { // range set?
          System.err.println("Setting timer task");
          int endFrame = X2indexX(rangeCursor.x);
          timer.schedule(new ClipObserver(clip, endFrame), 50, 50);
        }
        System.err.println("Starting clip.");
        clip.start();
      }
    }
  }
});

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

clip.setFramePosition(0);  // Must always rewind!
clip.start();

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

clip.setFramePosition(0); // rewind to the beginning

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

clip.setFramePosition(0);
  clip.loop( Clip.LOOP_CONTINUOUSLY );
} else {

代码示例来源:origin: robo-code/robocode

private Clip next() {
    Clip c = clips[idx];
    idx = (idx + 1) % clips.length;
    c.stop();
    c.setFramePosition(0);
    return c;
  }
}

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

File afile = new File(audioFilePath);
AudioInputStream astream = AudioSystem.getAudioInputStream(afile);
Clip audio = AudioSystem.getClip();
audio.open(astream);
audio.setFramePosition(0);
audio.start();

代码示例来源:origin: threerings/playn

@Override
protected boolean playImpl() {
 impl.setFramePosition(0);
 if (looping) {
  impl.loop(Clip.LOOP_CONTINUOUSLY);
 } else {
  impl.start();
 }
 return true;
}

代码示例来源: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: io.playn/playn-java-base

@Override
protected boolean playImpl() {
 impl.setFramePosition(0);
 if (looping) {
  impl.loop(Clip.LOOP_CONTINUOUSLY);
 } else {
  impl.start();
 }
 return true;
}

代码示例来源:origin: mikaelhg/openblocks

public void play() {
    if (SoundManager.isSoundEnabled()) {
      clip.setFramePosition(0);
      clip.loop(0);
    }
  }
}

代码示例来源:origin: playn/playn

@Override
protected boolean playImpl() {
 impl.setFramePosition(0);
 if (looping) {
  impl.loop(Clip.LOOP_CONTINUOUSLY);
 } else {
  impl.start();
 }
 return true;
}

代码示例来源:origin: com.googlecode.playn/playn-java

@Override
protected boolean playImpl() {
 impl.setFramePosition(0);
 if (looping) {
  impl.loop(Clip.LOOP_CONTINUOUSLY);
 } else {
  impl.start();
 }
 return true;
}

代码示例来源: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: org.jvnet.hudson/netx

/**
 * Plays the clip from the beginning.
 */
public void play() {
  if (clip == null)
    return;
  // applet audio clip resets to beginning when played again
  clip.stop();
  clip.setFramePosition(0);
  clip.start();
}

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

File soundFile = new File("/usr/share/sounds/generic.wav");
Clip clip = AudioSystem.getClip();
AudioInputStream inputStream = AudioSystem.getAudioInputStream(soundFile);
clip.open(inputStream);

while (System.in.read() == '\n') {
  clip.stop();
  clip.setFramePosition(0);
  clip.start();
}

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

File soundFile = new File("path_to_file\\doorbell.wav");
Clip clip = AudioSystem.getClip();
AudioInputStream inputStream = AudioSystem.getAudioInputStream(soundFile);
clip.open(inputStream);
clip.stop();//to avoid overlaps
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

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

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

public void play(){
  try{
    if(clip == null) return;
    stop();
    clip.setFramePosition(0);
    clip.start();
    active = true;
  } catch (Exception e) {
    p.print("Audio Failed to play", PrintTypes.ERROR);
    throw e;
  }
}

相关文章