I am using MediaPlayer to play radio stream. The problem occurs when I background the main activity which plays the stream.
When the phone uses too much resources (for example while trying to display a list of installed applications) the stream stopps. I suspect, that Android shuts down the stream in order to save up some resources.
This is how I prepare the mediaplayer when I start:
radioPlayer=new MediaPlayer();
radioPlayer.setDataSource(streamLocation); //with a try/catch of course in the full code
radioPlayer.prepareAsync();
radioPlayer.seekTo(0);
radioPlayer.setOnInfoListener(this);
radioPlayer.setOnPreparedListener(new OnPreparedListener(){
public void onPrepared(MediaPlayer mp)
radioPlayer.start();
});
It is all running on the main thread.