Exemple #1
0
  /** @hide */
  protected int setProgress() {
    if (mPlayer == null || mDragging) {
      return 0;
    }
    int position = mPlayer.getCurrentPosition();
    int duration = mPlayer.getDuration();
    /// M: add log for seldom ALPS01020394. @{
    MmsLog.d(
        "MmsMediaController", "setProgress, position: " + position + ", duration: " + duration);
    /// @}
    if (mProgress != null) {
      if (duration > 0) {
        // use long to avoid overflow
        long pos = 1000L * position / duration;
        mProgress.setProgress((int) pos);
      }
      int percent = mPlayer.getBufferPercentage();
      mProgress.setSecondaryProgress(percent * 10);
    }

    if (mEndTime != null) mEndTime.setText(stringForTime(duration));
    if (mCurrentTime != null) mCurrentTime.setText(stringForTime(position));

    // If duration is short, refresh every 100ms
    if (duration < 10000) {
      return 900;
    }
    return position;
  }
Exemple #2
0
        public void onClick(View v) {
          int pos = mPlayer.getCurrentPosition();
          pos += 15000; // milliseconds
          mPlayer.seekTo(pos);
          setProgress();

          show(sDefaultTimeout);
        }
  private int setProgress() {
    if (mPlayer == null || mDragging) {
      return 0;
    }
    int position = mPlayer.getCurrentPosition();
    int duration = mPlayer.getDuration();
    if (mProgress != null) {
      if (duration > 0) {
        // use long to avoid overflow
        long pos = 1000L * position / duration;
        mProgress.setProgress((int) pos);
      }
      int percent = mPlayer.getBufferPercentage();
      mProgress.setSecondaryProgress(percent * 10);
    }

    if (mEndTime != null) mEndTime.setText(stringForTime(duration));
    if (mCurrentTime != null) mCurrentTime.setText(stringForTime(position));

    return position;
  }
  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(generateTime(mDuration));
    if (mCurrentTime != null) mCurrentTime.setText(generateTime(position));

    return position;
  }