audio streaming in Android with the MediPlayer class

99封情书 提交于 2019-12-12 00:30:03

问题


I'm testing the audio streaming in Android with the MediPlayer class. I want to develop an application to play web radios. The streaming over http works. The code below work fine on emulator with Froyo(v. 2.2) but didn't work with Eclair (v. 2.1)

// in onStartCommand   
String url = "http://........"; // your URL here
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(url);  
mediaPlayer.prepareAsync(); // might take long! (for buffering, etc)

// in onPrepared
mediaPlayer.start();

But my app should also work on Eclair (v. 2.1) and I want to know how MediaPlayer work on it.

Someone has any experience with audio streaming in Android?


回答1:


I had a similar problem. When I declared onPreparedListener my track was already loaded. So onPreparedListener didn't work..



来源:https://stackoverflow.com/questions/7050637/audio-streaming-in-android-with-the-mediplayer-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!