0

I'have included Exoplayer in a app, Client is requesting that user should watch the full video and close the screen. I'have implemented PlayerEventListener for identifying the finished state, But didn't find any callback or a way to stop user seeking action. Please help me here how to stop seeking the video.

 private Player.EventListener exoEventListener = new Player.EventListener() {
        @Override
        public void onTimelineChanged(Timeline timeline, Object manifest) {}
        @Override
        public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {}
        @Override
        public void onLoadingChanged(boolean isLoading) {}
        @Override
        public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
            switch(playbackState) {
                case Player.STATE_BUFFERING:
                    break;
                case Player.STATE_ENDED:
                    isVideoFinished = true;
                    videoSectionListener.onVideoFinished();
                    break;
                case Player.STATE_IDLE:
                    break;
                case Player.STATE_READY:
                    break;
                default:
                    break;
            }
        }

        @Override
        public void onRepeatModeChanged(int repeatMode) {}
        @Override
        public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {}
        @Override
        public void onPlayerError(ExoPlaybackException error) {}
        @Override
        public void onPositionDiscontinuity(int reason) {}
        @Override
        public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {}
        @Override
        public void onSeekProcessed() {}
    }; 
Voora Tarun
  • 1,266
  • 1
  • 20
  • 38
  • are you talking about the default view that pop's up when video start playing having media controls ? – Gautam Mar 22 '18 at 18:27
  • comment to the sample code above: You may want to use DefaultEventListener, so you can only override the onPlayerStateChanged method while all other stay no-op. – marcbaechinger Mar 24 '18 at 17:09

2 Answers2

1

If you are referring to the seek bar shown by the PlayerView of the ExoPlayer. You can just use a simple SurfaceView instead of the PlayerView.

https://google.github.io/ExoPlayer/doc/reference/index.html?com/google/android/exoplayer2/ui/PlayerView.html

1

On the UI side of things you can avoid showing the controller with

app:use_controller="false"

This way the UI for seeking does not show.

If you still want to have the other UI element visible (like play/pause) you can customize the controller for what you want. There is a blog post about customizing the UI on Medium.

marcbaechinger
  • 2,759
  • 18
  • 21