I've made a basic radio player, the code that makes it play is below and works perfectly except for the setWakeMode method. When I turn my phone onto standby, the audio will play well for up to 2 minutes, after which, it begins to stop and start. Any ideas?
N.B. radioPlayer is an instance of MediaPlayer.
public boolean startRadio()
{
try
{
String url = getString(R.string.radioURL); // Radio url.
radioPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
radioPlayer.setDataSource(url);
radioPlayer.prepare(); // might take long! (for buffering, etc)
radioPlayer.setWakeMode(this.getApplicationContext(), PowerManager.PARTIAL_WAKE_LOCK);
radioPlayer.start();
return true;
}
catch(Exception e)
{
showAlert(getString(R.string.error), getString(R.string.radioError));
radioPlayer.release();
radioPlayer = new MediaPlayer();
return false;
}
}
UPDATE: After reviewing another thread elsewhere, I've discovered that this problem seems to be unique to HTC phones, in fact, my Samsung Galaxy Tab survives even without the wake lock at all. Any ideas?