VideoView getDuration - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for VideoView getDuration method.

This code example shows how to use the following methods:getDuration, start
            public void onPrepared(MediaPlayer mp) {
                // 3,4秒でMediaControllerが消えちゃうので 
                // 常に表示させておきたいんだけど 
                // showメソッドが期待通りに動作してくれない 
                // durationは正しく取得できてる。 
                int duration = mVideoView.getDuration();
                mMediaController.show(duration);
                // リファレンスを信じて0にしてもダメ 
//                mMediaController.show(0); 
 
                // まぁ気にせず再生スタート! 
                mVideoView.start();
            } 
        }); 
    } 
 
    public void onPickAndVideoViewButton(View view) {
        startVideoPicker(1); 
    } 
 
6
CodeRank
This code example shows how to use the following methods:canSeekForward, getDuration, isPlaying, seekTo, start
              
       // Don't start until ready to play.  The arg of seekTo(arg) is the start point in 
       // milliseconds from the beginning. In this example we start playing 1/5 of 
       // the way through the video if the player can do forward seeks on the video. 
        
       if(videoPlayer.canSeekForward()) videoPlayer.seekTo(videoPlayer.getDuration()/5);
       videoPlayer.start();
       Log.i("IS PLAYING", Boolean.toString(videoPlayer.isPlaying()));
    } 
     
    /** This callback will be invoked when the file is finished playing */ 
    @Override 
    public void onCompletion(MediaPlayer  mp) {
       // Statements to be executed when the video finishes. 
       this.finish();	
    } 
     
    /**  Use screen touches to toggle the video between playing and paused. */ 
    @Override 
    public boolean onTouchEvent (MotionEvent ev){
6
CodeRank
This code example shows how to use the following methods:getCurrentPosition, getDuration, isPlaying, pause, seekTo
 
    // 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();

6
CodeRank
This code example shows how to use the following methods:getCurrentPosition, getDuration, stopPlayback
    	super.onStart(); 
    } 
	@Override 
	public void onPause() { 
    	// Stop video when the activity is pause. 
    	mPositionWhenPaused = mVideoView.getCurrentPosition();
    	mVideoView.stopPlayback();
    	Log.d(TAG, "OnStop: mPositionWhenPaused = " + mPositionWhenPaused);
    	Log.d(TAG, "OnStop: getDuration  = " + mVideoView.getDuration());
 
    	super.onPause(); 
    } 
	@Override 
	public void onResume() { 
    	// Resume video player 
    	if(mPositionWhenPaused >= 0) {
    		mVideoView.seekTo(mPositionWhenPaused);
    		mPositionWhenPaused = -1;
    	} 
 
6
CodeRank
This code example shows how to use the following methods:getCurrentPosition, getDuration, isPlaying, pause, seekTo
 
    // 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();

6
CodeRank
This code example shows how to use the following methods:getDuration, seekTo, setVideoURI
    } 
 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
 
        VideoView view = new VideoView(getActivity());
 
        if (filePath != null){
            view.setVideoURI(Uri.fromFile(new File(filePath)));
//            view.start(); 
            int duration = view.getDuration();
            view.seekTo(duration);
        } 
 
        return view;
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getCurrentPosition, getDuration, suspend
        } 
    } 
 
    public void onPause() { 
        mHandler.removeCallbacksAndMessages(null);
        setBookmark(mVideoView.getCurrentPosition(), mVideoView.getDuration());
 
        mVideoView.suspend();
    } 
 
    public void onResume() { 
        mVideoView.resume();
    } 
 
    public void onDestroy() { 
        mVideoView.stopPlayback();
    } 
 
    public boolean onError(MediaPlayer player, int arg1, int arg2) {
        mHandler.removeCallbacksAndMessages(null);
5
CodeRank
This code example shows how to use the following methods:getCurrentPosition, getDuration, stopPlayback
 
	@Override 
	public void onPause() 
	{ 
		// Stop video when the activity is pause. 
		mPositionWhenPaused = mVideoView.getCurrentPosition();
		mVideoView.stopPlayback();
		// CHECKSTYLE:OFF 
		Log.d(TAG, "OnStop: mPositionWhenPaused = " + mPositionWhenPaused);
		Log.d(TAG, "OnStop: getDuration  = " + mVideoView.getDuration());
		// CHECKSTYLE:ON 
		super.onPause(); 
	} 
 
	@Override 
	public void onStop() 
	{ 
 
		super.onStop(); 
	} 
5
CodeRank
This code example shows how to use the following methods:getCurrentPosition, getDuration
 
    } 
    @Override 
    public void onBackPressed() { 
        super.onBackPressed(); 
        mMediaPlayer.getDuration();
        mMediaPlayer.getCurrentPosition();
    } 
 
} 
5
CodeRank
This code example shows how to use the following methods:getDuration, seekTo
	 */ 
	public void onStopTrackingTouch(SeekBar seekBar) {
 
		manejador.removeCallbacks(mUpdateTimeTask);
 
		int duracionTotal = VVvideo.getDuration();
		int posicionActual = progresoATimer(seekBar.getProgress(),
				duracionTotal);
 
		VVvideo.seekTo(posicionActual);
 
		// Actualizar el timmer. 
		updateProgressBar(); 
	} 
 
	/** 
	 * Actualizar la seek bar. 
	 */ 
	public void updateProgressBar() { 
		manejador.postDelayed(mUpdateTimeTask, 100);
4
CodeRank

Related VideoView getDuration Questions & Answers: