Code example for VideoView

Methods: getCurrentPositiongetDurationpauseseekTostart

0
 
    // This updates the time bar display (if necessary). It is called by 
    // mProgressChecker and also from places where the time bar needs 
    // to be updated immediately. 
    private int setProgress() { 
        mVideoPosition = mVideoView.getCurrentPosition();
        // If the video position is smaller than the starting point of trimming, 
        // correct it. 
        if (mVideoPosition < mTrimStartTime) {
            mVideoView.seekTo(mTrimStartTime);
            mVideoPosition = mTrimStartTime;
        } 
        // If the position is bigger than the end point of trimming, show the 
        // replay button and pause. 
        if (mVideoPosition >= mTrimEndTime && mTrimEndTime > 0) {
            if (mVideoPosition > mTrimEndTime) {
                mVideoView.seekTo(mTrimEndTime);
                mVideoPosition = mTrimEndTime;
            } 
            mController.showEnded();
            mVideoView.pause();
        } 
 
        int duration = mVideoView.getDuration();
        if (duration > 0 && mTrimEndTime == 0) {
            mTrimEndTime = duration;
        } 
        mController.setTimes(mVideoPosition, duration, mTrimStartTime, mTrimEndTime);
        return mVideoPosition;
    } 
 
    private void playVideo() { 
        mVideoView.start();
        mController.showPlaying();
        setProgress(); 
    } 
 
    private void pauseVideo() {