【发布时间】:2015-08-03 22:01:44
【问题描述】:
使用this post 我能够找到如何读取 mp3 文件,但我仍然对如何实际使用它感到困惑。
File file = new File(filename);
AudioInputStream in= AudioSystem.getAudioInputStream(file);
AudioInputStream din = null;
AudioFormat baseFormat = in.getFormat();
AudioFormat decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED,
baseFormat.getSampleRate(),
16,
baseFormat.getChannels(),
baseFormat.getChannels() * 2,
baseFormat.getSampleRate(),
false);
din = AudioSystem.getAudioInputStream(decodedFormat, in);
在这些声明之后,你如何使用din?我知道循环看起来像这样:
while (/*What do I put here??*/){
int currentByte = din.read();
}
换句话说,我只是想问如何从 mp3 文件中读取整个字节数组,在循环中一次一个地检查它们。
【问题讨论】: