int minSize =AudioTrack.getMinBufferSize( 45100, AudioFormat.CHANNEL_OUT_MONO, AudioFormat.ENCODING_PCM_16BIT );
track = new AudioTrack( AudioManager.STREAM_MUSIC,45100 ,
AudioFormat.CHANNEL_OUT_STEREO, AudioFormat.ENCODING_PCM_16BIT,
minSize, AudioTrack.MODE_STREAM);
track.setStereoVolume(1f,1f);
while(true)
{
Log.e(""," sizewe are using for track buffer is "+minSize);
int i = 0; // Read the file into the "music" array
music=new short[4188];
while (dis.available() > 0)
{
music[i] = dis.readShort();
i++;
if(i==4188)
break;
}
Log.e("","music lengh= "+music.length+" and dis.available="+dis.available());
track.play();
track.write(music,0, music.length);
track.flush();
track.stop();
}
有人告诉我当我们使用bytebuffer在audiotrack中播放大型mp3文件时如何解码声音,我想在播放歌曲时实时解码它...这里我从.aiff文件获取歌曲这是一个pcm格式 第一:我想通过audiotrack课程播放mp3文件 第二:.wav也是一个pcm文件,但它没有播放。
thanks in advance