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
.
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);
}
my bad was I was using PlayerControlView instead of PlayerView
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With