Ejemplo n.º 1
0
        @Override
        public void onProgressChanged(SeekBar bar, int progress, boolean fromuser) {
          if (!fromuser) return;

          long newposition = (mDuration * progress) / 1000;
          String time = StringUtils.generateTime(newposition);
          if (mInstantSeeking) mPlayer.seekTo(newposition);
          if (mInfoView != null) mInfoView.setText(time);
          if (mCurrentTime != null) mCurrentTime.setText(time);
        }
Ejemplo n.º 2
0
  private long setProgress() {
    if (mPlayer == null || mDragging) return 0;

    long position = mPlayer.getCurrentPosition();
    long duration = mPlayer.getDuration();
    if (mProgress != null) {
      if (duration > 0) {
        long pos = 1000L * position / duration;
        mProgress.setProgress((int) pos);
      }
      int percent = mPlayer.getBufferPercentage();
      mProgress.setSecondaryProgress(percent * 10);
    }

    mDuration = duration;

    if (mEndTime != null) mEndTime.setText(StringUtils.generateTime(mDuration));
    if (mCurrentTime != null) mCurrentTime.setText(StringUtils.generateTime(position));

    return position;
  }