private int setProgress() { if (mFensterPlayer == null || mDragging) { return 0; } int position = mFensterPlayer.getCurrentPosition(); int duration = mFensterPlayer.getDuration(); if (mProgress != null) { if (duration > 0) { // use long to avoid overflow long pos = 1000L * position / duration; mProgress.setProgress((int) pos); } int percent = mFensterPlayer.getBufferPercentage(); mProgress.setSecondaryProgress(percent * 10); } if (mEndTime != null) { mEndTime.setText(stringForTime(duration)); } if (mCurrentTime != null) { mCurrentTime.setText(stringForTime(position)); } final int playedSeconds = position / 1000; if (lastPlayedSeconds != playedSeconds) { lastPlayedSeconds = playedSeconds; } return position; }
public void onProgressChanged( final SeekBar bar, final int progress, final boolean fromuser) { if (!fromuser && !mManualDragging) { // We're not interested in programmatically generated changes to // the progress bar's position. return; } long duration = mFensterPlayer.getDuration(); long newposition = (duration * progress) / 1000L; mFensterPlayer.seekTo((int) newposition); if (mCurrentTime != null) { mCurrentTime.setText(stringForTime((int) newposition)); } }