1
剛開始播放音頻...開始播放,緩衝區繼續前進,但突然停止。當歌曲到達緩衝區時,音樂停止。然後按下去嵌套的歌曲,但同樣的事情發生。任何想法?音頻在一段時間後停止播放
private void startPlay(String file, String name)
{
Log.i("Selected: ", file);
tv_selelctedFile.setText(name);
//progressControlSeekbar.setProgress(0);
int maxVolume = mediaPlayer.getDuration();
int curVolume = mediaPlayer.getCurrentPosition();
progressControlSeekbar.setMax(maxVolume);
progressControlSeekbar.setProgress(curVolume);
progressControlSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
public void onStopTrackingTouch(SeekBar seekBar)
{
isMoveingSeekBar = false;
}
public void onStartTrackingTouch(SeekBar seekBar)
{
isMoveingSeekBar = true;
}
public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser)
{
if(isMoveingSeekBar)
{
mediaPlayer.seekTo(progress);
Log.i("OnSeekBarChangeListener","onProgressChanged");
}
}
});
mediaPlayer.stop();
mediaPlayer.reset();
try {
mediaPlayer.setDataSource(file);
mediaPlayer.prepare();
mediaPlayer.start();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
progressControlSeekbar.setMax(mediaPlayer.getDuration());
playButton.setImageResource(android.R.drawable.ic_media_pause);
updatePosition();
isStarted = true;
}