本文整理了Java中javax.sound.sampled.Clip.getMicrosecondPosition()
方法的一些代码示例,展示了Clip.getMicrosecondPosition()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Clip.getMicrosecondPosition()
方法的具体详情如下:
包路径:javax.sound.sampled.Clip
类名称:Clip
方法名:getMicrosecondPosition
暂无
代码示例来源:origin: ddf/Minim
public int getMillisecondPosition()
{
return (int)c.getMicrosecondPosition() / 1000;
}
代码示例来源:origin: UNIVALI-LITE/Portugol-Studio
public long getPosicaoAtualMusica()
{
if(clipTime>0)
{
return clipTime;
}
return clip.getMicrosecondPosition();
}
代码示例来源:origin: com.github.bloodshura/shurax-assets
@Nonnull
@Override
public Duration getPosition() {
if (isPlaying()) {
return Duration.ofNanos(TimeUnit.MICROSECONDS.toNanos(clip.getMicrosecondPosition()));
}
return null;
}
代码示例来源:origin: com.github.nifty-gui/nifty-pauls-soundsystem
/**
* Calculates the number of milliseconds since the channel began playing.
* @return Milliseconds, or -1 if unable to calculate.
*/
@Override
public float millisecondsPlayed()
{
switch( channelType )
{
case SoundSystemConfig.TYPE_NORMAL:
if( clip == null )
return -1;
return clip.getMicrosecondPosition() / 1000f;
case SoundSystemConfig.TYPE_STREAMING:
if( sourceDataLine == null )
return -1;
return sourceDataLine.getMicrosecondPosition() / 1000f;
default:
return -1;
}
}
/**
代码示例来源:origin: nroduit/Weasis
void tick() {
if (clip.isActive()) {
audioPosition = (int) (clip.getMicrosecondPosition() / 1000);
progress.setValue(audioPosition);
} else {
reset();
}
}
代码示例来源:origin: ddf/Minim
public void play()
{
if ( c.getMicrosecondPosition() != c.getMicrosecondLength() )
{
c.start();
playing = true;
}
}
代码示例来源: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
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: UNIVALI-LITE/Portugol-Studio
public void pausa(boolean fechaClip)
{
if (clip == null)
{
return;
}
clipTime=clip.getMicrosecondPosition();
clip.stop();
clip.flush();
if (fechaClip)
{
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();
}
}
内容来源于网络,如有侵权,请联系作者删除!