io.vov.vitamio.utils.StringUtils Java Examples

The following examples show how to use io.vov.vitamio.utils.StringUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MediaController.java    From video-player with MIT License 6 votes vote down vote up
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;
}
 
Example #2
Source File: MediaController.java    From BambooPlayer with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #3
Source File: MediaController.java    From Vitamio with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #4
Source File: MediaController.java    From react-native-android-vitamio with MIT License 6 votes vote down vote up
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;
}
 
Example #5
Source File: MediaController.java    From NetEasyNews with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example #6
Source File: MediaController.java    From HPlayer with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #7
Source File: MediaController.java    From MyHearts with Apache License 2.0 6 votes vote down vote up
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;
    }
 
Example #8
Source File: MediaController.java    From HPlayer with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #9
Source File: MediaController.java    From video-player with MIT License 5 votes vote down vote up
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);
}
 
Example #10
Source File: MediaController.java    From MyHearts with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #11
Source File: MediaController.java    From NetEasyNews with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #12
Source File: PlayerActivity.java    From HPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    mHandler.postDelayed(updateSeekBarThread, UPDATE_INTERVAL);
    if (mVideoView.getDuration() != 0) {
        mSeekBar.setProgress((int) (mVideoView.getCurrentPosition() /
                (float) mVideoView.getDuration() * 1000));
        mCurrentTime.setText(StringUtils.generateTime(
                mVideoView.getCurrentPosition()));
        mTotalTime.setText(StringUtils.generateTime(
                mVideoView.getDuration()));
    }
}
 
Example #13
Source File: MediaController.java    From react-native-android-vitamio with MIT License 5 votes vote down vote up
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);
}
 
Example #14
Source File: VideoListAdapter.java    From HPlayer with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.video_list_item, null);
        holder = new ViewHolder();
        holder.infoLayout = convertView.findViewById(R.id.info_layout);
        holder.name = (TextView) convertView.findViewById(R.id.media_name);
        holder.size = (TextView) convertView.findViewById(R.id.media_size);
        holder.path = (TextView) convertView.findViewById(R.id.media_path);
        holder.duration = (TextView) convertView.findViewById(R.id.media_duration);
        holder.image = (ImageView) convertView.findViewById(R.id.media_image);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    Utility.resizeImageViewOnScreenSize(mContext, holder.image, 3, 10, 4, 3);
    ViewGroup.LayoutParams lp = holder.infoLayout.getLayoutParams();
    lp.height = holder.image.getLayoutParams().height;

    MediaInfo mediaInfo = getItem(position);
    holder.name.setText(mediaInfo.getName());
    holder.size.setText(FileManager.sizeAddUnit(mediaInfo.getSize()));
    holder.duration.setText(StringUtils.generateTime(mediaInfo.getDuration()));
    holder.path.setText(mediaInfo.getPath());
    if (mediaInfo.getThumbnailPath() != null) {
        Picasso.with(mContext).load("file://" + mediaInfo.getThumbnailPath())
                .error(R.drawable.image_default_bg).into(holder.image);
    } else {
        holder.image.setImageResource(R.drawable.image_default_bg);
    }

    return convertView;
}
 
Example #15
Source File: MediaController.java    From Vitamio with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #16
Source File: MediaController.java    From BambooPlayer with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #17
Source File: DlnaFragment.java    From HPlayer with Apache License 2.0 4 votes vote down vote up
@Override
public void run() {
    mSeekBar.setProgress((int) (currentPosition / (float) duration * 1000));
    mCurrentTime.setText(StringUtils.generateTime(currentPosition));
    mTotalTime.setText(StringUtils.generateTime(duration));
}