eneim / toro

Video list auto playback made simple, specially built for RecyclerView
Apache License 2.0
1.42k stars 253 forks source link

Check duration of video during video playing #467

Closed saadbzu closed 4 years ago

saadbzu commented 4 years ago

During a video playing, how i check how much video is played? For example if a video of length 20 second is playing, i want to trigger an even when video complete its 5 seconds.

eneim commented 4 years ago

@saadbzu The Helper class has this method. You can get the PlaybackInfo and use its position for your purpose.

saadbzu commented 4 years ago

@eneim I need the listener while video playing. PlaybackInfo calls only once when video play. Please give me some example code

eneim commented 4 years ago

@saadbzu There is no such listener, because no one would tell you every second about things you can always get. You can do it yourself using Handler with postDelayed.

saadbzu commented 4 years ago

@eneim i use timer of 10 second in onPlaying() listener and then check the response in log. When 1st video in recyclerview play it works fine but when i scroll to 2nd video it run 2 time. for 3rd,4th,5th.... it work fine but only for 2nd video this method play two time.

helper.initialize(container, playbackInfo); helper.addPlayerEventListener(new EventListener() { @Override public void onFirstFrameRendered() { }

        @Override
        public void onBuffering() {

        }

        @Override
        public void onPlaying() {
            videoThumbnailImage.setVisibility(View.GONE);
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    // 10 second complete
                }
            }, 10000);
        }

        @Override
        public void onPaused() {

        }

        @Override
        public void onCompleted() {

        }
    });