1

i am new to android i want to develop application of video player in this video player i need to integrate seekbar. i was stuck in this scenario. the scenario is the seekbar seeking up to video length,at the end of the video(video is finished to play ) seekbar set to zero plz help me how can i implement this scenario.

i do not know how to implement

1)how to set seekbar seeking up to video length/duration
2)if video is fully played how to set seekbar in start position/initial position(before seeking video position)
3)how can i get video is fully played

please any one help me as soon as possible

Harshad Pansuriya
  • 20,189
  • 8
  • 67
  • 95
yogi
  • 43
  • 1
  • 10

2 Answers2

1

i found these links may be they help you:

How to play a video using videoview controlled by a seekBar or Progress bar?

How to use a Seekbar in android as a seekBar as well as a progressBar simultaneously?

How can i change the position of a progressBar, after the duration of a videoView?

package com.coderzheaven.pack;

import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;

public class VideoViewDemo extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
                   setContentView(R.layout.main);
                   showVideo();
               }
            private void showVideo()
            {
                VideoView vd = (VideoView)findViewById(R.id.videoview);
                Uri uri = Uri.parse("android.resource://"+ getApplication().getPackageName() +"/"+R.raw.asal);
                MediaController mc = new MediaController(this);
                vd.setMediaController(mc);
                vd.setVideoURI(uri);
                vd.start();
                vd.setOnCompletionListener(new OnCompletionListener() {
                    @Override
                    public void onCompletion(MediaPlayer mp) {
//you can set seekbar position here with help of vd.seekTo(progress);
                            Toast.makeText(getApplicationContext(), "Video completed", Toast.LENGTH_LONG).show();
                        }
                    });
                }
    }
Community
  • 1
  • 1
Hamad
  • 5,096
  • 13
  • 37
  • 65
  • thanks for your reply hamad: but i cannot get how to set initial position of seekbar after video played fully.can u please help me how to set seeekbar set to initial value after video fully played – yogi Aug 29 '13 at 07:58
  • have you applied this method to set the seek bar postition seekBar.setProgress(0); @yogi – Hamad Aug 29 '13 at 12:15
  • also try this videoView.seekTo(progress); @yogi – Hamad Aug 29 '13 at 12:17
  • it will work hamad but i need to know where i have to put this code. Actually i want to put this code to end of video played but i need to know when the video will end how can i calculate and where i put this code ;@hamad – yogi Aug 29 '13 at 12:39
  • oh.. setOnCompletionListener(MediaPlayer.OnCompletionListener l) – Hamad Aug 29 '13 at 12:45
  • set that oncompletion listner to video view and in this set videoView.seekto(progress) – Hamad Aug 29 '13 at 12:46
  • could you please put some program for me@hamad – yogi Aug 29 '13 at 12:47
  • i have added some sample code for you..if it is what you need then mark this as answer. – Hamad Aug 29 '13 at 13:03
  • @hamad...very very thanks hamad..it works great.now i want one more help hamad..how to set seekbar seeking value up to video length – yogi Aug 30 '13 at 04:02
  • mark my solution as answer,and add point so that it can help others too! – Hamad Aug 30 '13 at 05:41
1

1)how to set seekbar seeking up to video length/duration

you can acheive this by using this code:

videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener()  {
            @Override
            public void onPrepared(MediaPlayer mp) {                         
                long duration = videoView.getDuration();
            }
        });

if this works mark this as answer for others help

Hamad
  • 5,096
  • 13
  • 37
  • 65
  • if i will give like this seekbar cannot move.it is still in same place only hamad – yogi Aug 30 '13 at 06:39
  • visit this may be it will help you http://stackoverflow.com/questions/7802645/in-android-how-to-get-the-progress-time-of-the-video-played-under-videoview – Hamad Aug 30 '13 at 08:01