无法理解Javax Clip setMicrosecondPosition。我错过了什么?

时间:2016-04-26 13:15:25

标签: java javasound seek javax.sound.sampled audioinputstream

我正在为音频片段添加一分钟(60*1000*1000 microseconds)并启动它,我只是第一次达到了预期的结果,即我到达音频文件中的正确位置。下次我在Clip对象上调用getMicrosecondPosition时,我得到了微秒的位置,好像我没有添加任何内容。为此行为附加了示例代码段和输出。我不能完全理解我做错了什么。

clip.stop();
currentPlaybackTime=clip.getMicrosecondPosition()+60L*1000*1000;
System.out.println("Playing from "+currentPlaybackTime+" ms i.e "+currentPlaybackTime/1000000.0+" seconds");
clip.setMicrosecondPosition((currentPlaybackTime));
System.out.println("Verifying: currentPlaybackTime is "+clip.getMicrosecondPosition());
clip.start();
System.out.println("Verifying 2: currentPlaybackTime is "+clip.getMicrosecondPosition());

输出

Playing from 63326000 ms i.e 63.326 seconds [Note:this is seeking to correct point in audio file!]
Verifying: currentPlaybackTime is 3326000 [Why not here?]
Verifying 2: currentPlaybackTime is 3326000 [and here?]
Play/Pause Clicked
Pausing at 5120000 ms 5.12 seconds

0 个答案:

没有答案