I am using MediaPlayer
's prepareAsync()
function.
My code looks like:
try {
mediaPlayer.setDataSource(stream_url);
mediaPlayer.prepareAsync();
} catch (Exception e) {
e.printStackTrace();
}
mediaPlayer.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.start();
}
});
The issue is that sometimes stream_url
is playing music, and sometimes stream_url
is not playing music. How can I notify the user if stream_url
is not playing music? Is there a timeout of some sort or an error I can catch? Nothing is currently being thrown, it just calls asycn then does nothing if there is no stream.