6

I'm working on ExoPlayer 2.6.0 for a Radio streaming app. Radio is playing is fine, but when i try to add seekTo for +/-30 seconds it always starts the streaming from 0. In the debug mode, player seeks to +30 seconds but as soon as setPlayWhenReady() is set it goes back to start from 0. It has been a long time i've been looking for this solution so decided to ask here. Any help will be appreciated.

Following is the code that i'm using for seekto operation.

ivForward.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                if (exoPlayer != null && Constants.isMediaPlaying) {
                    exoPlayer.setPlayWhenReady(false);
                    Constants.isMediaPlaying = false;
                    long bufferPosition = exoPlayer.getBufferedPosition();
                    long currentPosition = exoPlayer.getCurrentPosition();
                    if ((currentPosition + 30000) < bufferPosition + 50) {
                        exoPlayer.setPlayWhenReady(false);
                        Constants.isMediaPlaying = false;
                        exoPlayer.seekTo(exoPlayer.getCurrentWindowIndex(), currentPosition + 30000);
                        exoPlayer.setPlayWhenReady(true);
                        Constants.isMediaPlaying = true;
                    }
                }
            } catch (Exception e) {
                MakeToast.show("Error moving forward");
            }
        }
    });

Thanks

Harry .Naeem
  • 1,037
  • 3
  • 16
  • 29
  • you solved your problem? – Tara Apr 16 '21 at 15:19
  • @Tara i opened a ticket in ExoPlayer forum and they said to update exoPlayer version and then after updating things looked good but not exactly i wanted. You can join their forum and you might be able to see something from there – Harry .Naeem Apr 19 '21 at 10:02
  • Same here, things look good but not exactly i wanted – Tara Apr 19 '21 at 11:30

0 Answers0