0
我试图加载一个OGG文件到AudioTrack,以便我可以管理播放速度并播放它。但是,我在“track [voiceIndex] = dis.readByte();”这行获得空指针异常。我想它会超出轨道阵列的范围。我真的不知道太多数据流,所以我只是有点复制这些代码。我很难理解它。任何帮助将不胜感激,谢谢。OGG音频到AudioTrack
.....
private AudioTrack voice = null;
private InputStream is = null;
private byte[] track = null;
private BufferedInputStream bis = null;
private DataInputStream dis = null;
.......
int playbackRate = 0;
is = getResources().openRawResource(sentences[index].voice);
bis = new BufferedInputStream(is, 8000);
dis = new DataInputStream(bis);
while (dis.available() > 0){
track[voiceIndex] = dis.readByte();
voiceIndex++;
}
voice.write(track, 0, track.length);
playbackRate = voice.getPlaybackRate();
voice.play();
或者,也许我可以使用SoundPool来改变播放速度? – lespommes
加油....任何人? – lespommes