player = new MediaPlayer();
try {
player.setDataSource(str_stream_url);
// player.setDataSource("http://cdn.concreteloop.com/wp-content/uploads/2011/01/Jennifer-Lopez-feat.-Pitbull-On-the-Floor.mp3");
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
player.setOnBufferingUpdateListener(new OnBufferingUpdateListener() {
public void onBufferingUpdate(MediaPlayer mp, int percent) {
playSeekBar.setSecondaryProgress(percent);
Log.i("Buffering", "" + percent);
}
});
它的工作中的Android 4.0版本,但它不是在安卓2.3.3工作..
我能做些什麼?
Thx。
「不工作」_以什麼方式_? logcat輸出中是否有任何異常或其他相關錯誤? – Michael
我在Logcat中看到了以下錯誤: 02-06 13:08:29.440:E/MediaPlayer(2448):開始在狀態4中調用 02-06 13:08:29.440:E/MediaPlayer(2448)錯誤(-38,0) 02-06 13:08:29.460:E/MediaPlayer(2448):錯誤(-38,0) – juniorCoder
'在狀態4開始調用'意味着您在調用'start'之前'prepareAsync'已完成。在準備完成時,您應該使用[onPreparedListener](https://developer.android.com/reference/android/media/MediaPlayer.OnPreparedListener.html)接收回調,並且在此之前不要調用「start」。 – Michael