yogi yogi - 5 months ago 47
Android Question

how to set seekbar progress set to zero if video is finished in android

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

Answer

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();
                        }
                    });
                }
    }