本文整理了Java中javax.sound.sampled.Clip.getMicrosecondLength()
方法的一些代码示例,展示了Clip.getMicrosecondLength()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Clip.getMicrosecondLength()
方法的具体详情如下:
包路径:javax.sound.sampled.Clip
类名称:Clip
方法名:getMicrosecondLength
暂无
代码示例来源:origin: ddf/Minim
public int getMillisecondLength()
{
return (int)c.getMicrosecondLength() / 1000;
}
代码示例来源:origin: UNIVALI-LITE/Portugol-Studio
public long getTamanhoMusica()
{
return clip.getMicrosecondLength();
}
代码示例来源:origin: com.github.bloodshura/shurax-assets
@Nonnull
@Override
public Duration getDuration() {
return Duration.ofNanos(TimeUnit.MICROSECONDS.toNanos(clip.getMicrosecondLength()));
}
代码示例来源:origin: stackoverflow.com
URL url = new URL("foo.wav");
Clip clip = AudioSystem.getClip();
AudioInputStream ais = AudioSystem.getAudioInputStream(url);
clip.open(ais);
System.out.println(clip.getMicrosecondLength());
代码示例来源:origin: stackoverflow.com
Clip clip = AudioSystem.getClip();
clip.open(AudioSystem.getAudioInputStream(new File("water-splash.wav")));
clip.start();
int lengthInMilliseconds = clip.getMicrosecondLength() * 1000;
Thread.sleep(lengthInMilliseconds);
代码示例来源:origin: net.mikera/mikera
public static void main(String[] args) {
Clip c=loadClip("mikera/sound/Thud.wav");
try {
c.start();
Thread.sleep(1000);
c.start();
Thread.sleep(c.getMicrosecondLength()/1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
代码示例来源:origin: ddf/Minim
public void play()
{
if ( c.getMicrosecondPosition() != c.getMicrosecondLength() )
{
c.start();
playing = true;
}
}
代码示例来源:origin: stackoverflow.com
class sound implements Runnable {
@Override
public void run() {
Clip clip = null; // take the declaration of the clip variable out of the try - catch
try {
AudioInputStream audioInputStream =
AudioSystem.getAudioInputStream(new File("/Users/babe/Desktop/Con1.wav").getAbsoluteFile());
clip = AudioSystem.getClip();
clip.open(audioInputStream);
clip.start();
Thread.sleep(clip.getMicrosecondLength() / 1000);
} catch(InterruptedException ex) {
clip.stop(); // <--- ADD THIS LINE
System.out.println("Cancelled 1!");
} catch (Exception ex) {
System.out.println("Error with playing sound.");
ex.printStackTrace();
}
}
}
代码示例来源:origin: stackoverflow.com
clip.open(audioInputStream);
clip.start();
Thread.sleep(clip.getMicrosecondLength() / 1000);
} catch(InterruptedException ex) {
System.out.println("Cancelled!");
代码示例来源:origin: stackoverflow.com
public void play(InputStream inputStream) {
try {
AudioInputStream soundIn = AudioSystem.getAudioInputStream(new BufferedInputStream(inputStream) );
AudioFormat format = soundIn.getFormat();
DataLine.Info info = new DataLine.Info(Clip.class, format);
Clip clip = (Clip) AudioSystem.getLine(info);
clip.open(soundIn);
clip.start();
sleep(clip.getMicrosecondLength() / 1000);// Thread.yield();
} catch (Exception e) {
log.warn("could not play");
e.printStackTrace();
}
}
private void sleep(long sleep) {
try {
Thread.sleep(sleep);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
}
}
代码示例来源:origin: ev3dev-lang-java/ev3dev-lang-java
/**
* Play a wav file. Must be mono, from 8kHz to 48kHz, and 8-bit or 16-bit.
* @param file the 8-bit or 16-bit PWM (WAV) sample file
*/
public void playSample(final File file) {
try (AudioInputStream audioIn = AudioSystem.getAudioInputStream(file.toURI().toURL())) {
Clip clip = AudioSystem.getClip();
clip.open(audioIn);
clip.start();
Delay.usDelay(clip.getMicrosecondLength());
clip.close();
} catch (IOException | LineUnavailableException | UnsupportedAudioFileException e) {
LOGGER.error(e.getLocalizedMessage(), e);
throw new RuntimeException(e);
}
}
代码示例来源:origin: stackoverflow.com
String filename="foo.wav";
Clip clip=AudioSystem.getClip();
AudioInputStream inputStream=AudioSystem.getAudioInputStream(new BufferedInputStream(Audio.class.getResourceAsStream(filename)));
if(inputStream!=null) {
clip.open(inputStream);
FloatControl gainControl=(FloatControl)clip.getControl(FloatControl.Type.MASTER_GAIN);
gainControl.setValue(+6.0f); // ?
clip.start();
// maybe do not wait?
while(clip.getMicrosecondLength()!=clip.getMicrosecondPosition())
Thread.yield(); // wait
// or at least don't wait here?
Thread.sleep(500);
clip.close();
}
代码示例来源: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
timerUpdate = true;
try {
long length = TimeUnit.NANOSECONDS.convert(clip.getMicrosecondLength(), TimeUnit.SECONDS);
long time = TimeUnit.NANOSECONDS.convert(clip.getMicrosecondPosition(), TimeUnit.SECONDS);
int progress = (int) Math.round(((double) time / (double) length) * 100d);
userUpdate = true;
try {
long length = clip.getMicrosecondLength();
int progress = slider.getValue();
long time = (long) (length * (progress / 100d));
代码示例来源:origin: nroduit/Weasis
audioLength = (int) (clip.getMicrosecondLength() / 1000);
代码示例来源:origin: stackoverflow.com
clip.open(stream);
clip.start();
while(clip.getMicrosecondLength() != clip.getMicrosecondPosition()) {}
代码示例来源:origin: stackoverflow.com
while(clip.getMicrosecondLength() != clip.getMicrosecondPosition()){
代码示例来源:origin: stackoverflow.com
Clip clip = AudioSystem.getClip();
clip.open(inputAIS);
long totalMicroSecond = clip.getMicrosecondLength();
} catch (UnsupportedAudioFileException e) {
代码示例来源:origin: ddf/Minim
meta = new BasicMetaData(filename, clip.getMicrosecondLength() / 1000, -1);
内容来源于网络,如有侵权,请联系作者删除!