我首先提到我有一個帶有幾個項目的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 –
嘗試過任何東西是的,因爲我不知道如何去做:) –