对于在线歌曲,只需将mp3Path赋值为相应的网址即可,如
mp3Path = "http://abv.cn/music/光辉岁月.mp3";
mediaPlayer.setDataSource(mp3Path);
对于seekBar的缓冲进度更新,只需
seekBar.setSecondaryProgress(pos);
具体如下:
1 mediaPlayer.setOnBufferingUpdateListener(new MediaPlayer.OnBufferingUpdateListener() { 2 @Override 3 public void onBufferingUpdate(MediaPlayer mp, int percent) { 4 int pos = seekBar.getMax() * percent/100; 5 seekBar.setSecondaryProgress(pos); 6 7 int currentProgress = 100 * mediaPlayer.getCurrentPosition() / mediaPlayer.getDuration(); 8 Log.d(currentProgress + "% play", percent + "% buffer"); 9 } 10 });
时间: 2024-11-04 12:42:42