Code example for VideoView

Methods: getCurrentPositiongetDurationpausestart, getBufferPercentage

0
	private int setProgress() { 
		if (mVideoView == null || mDragging) {
			return 0; 
		} 
 
		int position = mVideoView.getCurrentPosition();
		int duration = mVideoView.getDuration();
		if (mSeekBar != null) {
			if (duration > 0) {
				long pos = 1000L * position / duration;
				mSeekBar.setProgress((int) pos);
			} 
			int percent = mVideoView.getBufferPercentage();
			mSeekBar.setSecondaryProgress(percent * 10);
		} 
 
		if (mStartText != null)
			mStartText.setText(stringForTime(duration));
		if (mEndText != null)
			mEndText.setText(stringForTime(position));
 
		return position;
	} 
 
	public void updatePausePlay() { 
		if (mPlayButton == null || mVideoView == null) {
			return; 
		} 
 
		if (mVideoView.isPlaying()) {
			mPlayButton.setImageResource(android.R.drawable.ic_media_pause);
		} else { 
			mPlayButton.setImageResource(android.R.drawable.ic_media_play);
		} 
	} 
 
	private void doPauseResume() { 
		if (mVideoView == null) {
			return; 
		} 
 
		if (mVideoView.isPlaying()) {
			mVideoView.pause();
		} else { 
			mVideoView.start();
		} 
		updatePausePlay(); 
	} 
 
	private static class MessageHandler extends Handler {