audio streaming in Android with the MediPlayer class
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?
I had a similar problem. When I declared onPreparedListener my track was already loaded. So onPreparedListener didn't work..
精彩评论