0
播放音頻文件時出現問題。當我輸入兩個詞如「嗨湯姆」,只有最後一個字是在玩。但在我的日誌貓似乎通過第一首歌詞。我的代碼錯了?或者有沒有解決這裏第一首歌曲,然後在這裏第二首歌曲?任何解決方案對我來說都可以,例如它可以在這些歌曲之間延遲。謝謝。 我還看到了關於nextsong的musicdroid代碼。但我是新來的android和我不能集成我的代碼。 musicdroidandroid播放兩首歌曲問題
public void function (String[][] word)
{
try{
for (int j=0;j<word.length;j++)
{
for(int i=0;i<word[j].length;i++)
{
System.out.println("word:"+word[j][i]);
if(word[j][i].equals("empty")==false)
{
mediaPlayer.reset();
mediaPlayer.setDataSource("/sdcard/voice/"+word[j][i]+".ogg");
mediaPlayer.prepare();
mediaPlayer.start();
System.out.println(word[j][i]+"-");
}
}
}
System.out.println("end");
}
catch(Exception e)
{
System.out.println("error:"+e.getMessage());
}
}
這裏是我的日誌貓。它似乎採取第一個聲音,但不玩。
04-04 09:58:18.934: INFO/System.out(363):word:hi
04-04 09:58:18.944: INFO/StagefrightPlayer(34): setDataSource('/sdcard/voice/hi.ogg')
04-04 09:58:19.024: DEBUG/AudioSink(34): bufferCount (4) is too small and increased to 12
04-04 09:58:19.024: INFO/System.out(363): hi-
04-04 09:58:19.024: INFO/System.out(363): word:tom
04-04 09:58:19.034: INFO/StagefrightPlayer(34): setDataSource('/sdcard/voice/tom.ogg')
04-04 09:58:19.114: DEBUG/AudioSink(34): bufferCount (4) is too small and increased to 12
04-04 09:58:19.124: INFO/System.out(363): tom-
04-04 09:58:19.124: INFO/System.out(363): end
謝謝您的回答。在listener中,我會額外添加任何代碼,如mediaPlayer.release();或只是離開它? – wseries 2011-04-04 18:15:40