7

ExoPlayer is not showing the video. I can listen the audio but video is not playing. I am using the Exoplayer in the Recyclerview.I only can see the black screen and listen to audio.I am not able to track the problem. I am playing the HLS video in the ExoPlayer.

Shikha Ratra
  • 697
  • 3
  • 12
  • 28

2 Answers2

1

I was also getting same issue few days back, now posting it here so that it can make someone's life easy since this problem appears very often when we use Exoplayer with RecyclerView.

Cause of the issue (in my case):

PlayerView was getting changed every time I came on the screen (due to the presence of RecyclerView)

I handled it by setting the player each time on the PlayerView object inside showLivePlayer() method which is called each time recycler view enabled screen opens to play the video.

    public void showLivePlayer(PlayerView playerView, String videoURL, String tokenURL, ProgressBar progressBar){

        mPlayerView = playerView;
        if(player != null)
            mPlayerView.setPlayer(player);  //THIS IS THE FIX

        mProgressBar = progressBar;
        //register event bus
        if (!EventBus.getDefault().isRegistered(this))
            EventBus.getDefault().register(this);

        shouldAutoPlay = true;
        bandwidthMeter = new DefaultBandwidthMeter();
        mediaDataSourceFactory = new DefaultDataSourceFactory(mContext,
                Util.getUserAgent(mContext, mContext.getString(R.string.app_name)), bandwidthMeter);
        window = new Timeline.Window();
        getLiveVideoToken(tokenURL, videoURL);
}
Shishupal Shakya
  • 1,632
  • 2
  • 18
  • 41
1

my bad was I was using PlayerControlView instead of PlayerView

Boy
  • 7,010
  • 4
  • 54
  • 68