I start by mentioning that I have a ListView with a few items.
I select an Item and I start MediaPlayer streaming an audio from URL using..
String url = "https://url/"+ MyFile + ".mp3";
mPlayer = new MediaPlayer();
mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mPlayer.setDataSource(url);
} catch (IllegalArgumentException e) {
Toast.makeText(this, "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (IOException e) {
e.printStackTrace();
}
try {
mPlayer.prepare();
} catch (IllegalStateException e) {
Toast.makeText(this, "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
} catch (IOException e) {
Toast.makeText(this, "You might not set the URI correctly!", Toast.LENGTH_LONG).show();
}
mPlayer.start();
mPlayer.setOnCompletionListener(new OnCompletionListener() {
public void onCompletion(MediaPlayer mPlayer) {
mPlayer.release();
}
});
I want though while MediaPlayer is playing to display an AlertDialog to turn off streaming is it possible?
Thank you.