3
我有一個媒體播放器,MP3播放器從URL。我想在從url加載音頻時顯示進度對話框。這是我的代碼..我是新人,所以如果你不能很好地理解我的問題,請不要介意。在此先感謝無法顯示的MP3媒體播放器ProgressDialog而準備
播放功能
public void playSong(int naatindex){
// Play song
tv = (TextView) this.findViewById(R.id.mywidget);
tv.setText("Buffering....");
tv.setSelected(true);
final ProgressDialog progressDialog = ProgressDialog.show(this,
"Loading Title", "Loading Message");
mp.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
if (progressDialog != null && progressDialog.isShowing()){
progressDialog.dismiss();
}
mp.start();
}
});
try {
mp.reset();
mp.setDataSource(naatpaths[naatindex]);
tv = (TextView) this.findViewById(R.id.mywidget);
tv.setSelected(true);
mp.prepare();
// Set focus to the textview
tv.setText(naattitles[naatindex]);
// Changing Button Image to pause image
btnPlay.setImageResource(R.drawable.btn_pause);
// set Progress bar values
songProgressBar.setProgress(0);
songProgressBar.setMax(100);
// Updating progress bar
updateProgressBar();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
謝謝這對我有用。 Thankkkkkkkkkkkksssssssssss –