我用过:
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 v4.0中运行但在Android 2.3.3中无法运行..
我该怎么办?
THX。
答案 0 :(得分:1)
此外,我在Android 2.3.3中尝试了此代码,但它无法正常工作..最后您可以看到错误。
Uri myUri = Uri
.parse("http://46.137.18.79:8000/;stream.nsv&type=mp3&autostart=true");
player = new MediaPlayer();
try {
if (player == null) {
this.player = new MediaPlayer();
} else {
player.stop();
player.reset();
}
player.setDataSource(this, myUri); // Go to Initialized state
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
player.setOnPreparedListener(this);
player.setOnBufferingUpdateListener(this);
player.setOnErrorListener(this);
player.prepareAsync();
Log.d(TAG, "LoadClip Done");
} catch (Throwable t) {
Log.d(TAG, t.toString());
}
02-06 13:49:03.730:E / MediaPlayer(2718):在状态1中停止呼叫
02-06 13:49:03.730:E / MediaPlayer(2718):错误(-38,0)
02-06 13:49:03.730:D / MediaPlayer(2718):无法在客户端打开文件,尝试服务器端
02-06 13:49:03.870:D / MyMain(2718):LoadClip完成
THX。