Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Callback on VideoView progress

I'm looking for a way to get a callback when a VideoView is playing, indicating the video progress. Something like described here, but for a VideoView. Polling the current progress every fixed duration seems a bad solution…

Is there any listener existing for this that I missed?

like image 929
Marc Plano-Lesay Avatar asked Feb 15 '23 11:02

Marc Plano-Lesay


2 Answers

You can use a thread to get the progress.

mRunnable = new Runnable() {
    public void run() {     
        Log.i(TAG, "::run: getCurrentPosition = " + mVideoView.getCurrentPosition());       
        if(mVideoView.isPlaying()){
            mHandler1.postDelayed(this, 250);                   
        }
    }
};
mHandler1.post(mRunnable);
like image 200
Shashika Avatar answered Feb 24 '23 12:02

Shashika


Runnable onEverySecond=new Runnable() {
            public void run() {
                if(seekbar != null) {
                    seekbar.setProgress(mPlayer.getCurrentPosition());
                }
                if(mPlayer.isPlaying()) {
                    System.out.println("inside runnable :::::: is playing  ");
                    seekbar.postDelayed(onEverySecond, 10);
                }
            }
        };
                seekbar.postDelayed(onEverySecond, 10);
like image 30
Aravi Avatar answered Feb 24 '23 13:02

Aravi