我首先提到我有一个带有几个项目的ListView。如何在mediaplayer播放时显示AlertDialog并使用它停止流式传输
我选择一个项目,我开始MediaPlayer的流媒体使用URL音频..
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();
}
});
我想,虽然同时MediaPlayer正在播放到显示AlertDialog关闭流这可能吗?
谢谢。
那么问题是什么?无法看到你用Dialog –
尝试过任何东西是的,因为我不知道如何去做:) –