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
.
Asked
Active
Viewed 4,711 times
7

Shikha Ratra
- 697
- 3
- 12
- 28
-
Which version you used for ExoPlayer? – Palak Aug 06 '16 at 12:32
-
@Palak compile 'com.google.android.exoplayer:exoplayer:r1.5.9' – Shikha Ratra Aug 06 '16 at 12:36
-
You test on which android version? – Palak Aug 06 '16 at 12:42
-
@Palak Tested on API 19.. – Shikha Ratra Aug 06 '16 at 12:46
-
@Palak its working if working normally using Activity only, in adapter its not working. – Shikha Ratra Aug 06 '16 at 12:47
-
@Sikha Oh I see, then you need to check context or compare both code – Palak Aug 06 '16 at 12:49
-
@Palak i took reference from there only. – Shikha Ratra Aug 06 '16 at 12:53
-
Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/120307/discussion-between-palak-and-shikha-ratra). – Palak Aug 06 '16 at 12:53
-
1I had the same problem, is your problem solved now? Please share your solution – Prasanna Sundar Aug 16 '16 at 15:04
-
@PrasannaSundar yes!! my problem is solved...i have added my edited code above... – Shikha Ratra Aug 17 '16 at 05:27
-
Can you just tell me what was the change you made? There is a bunch of code that is changed above... I have been facing this problem for a week – Prasanna Sundar Aug 17 '16 at 06:36
-
you can also add it as an answer below. Pls! – Prasanna Sundar Aug 17 '16 at 06:46
-
@PrasannaSundar i have change the whole code.. that code was not creating the surface to display video...u can use this code if it helpful to you. – Shikha Ratra Aug 17 '16 at 07:00
-
@ShikhaRatra Thanks! Even I have the same surface changing issue, but I am using TIF where surface will be given to me with interface. Is the surface null for you? was it the problem? – Prasanna Sundar Aug 17 '16 at 07:02
-
@PrasannaSundar yes..the surface was not creating in that code that's y only audio is playing..i have added the comment in the code from where you can start changing the code...are you using the exoplayer in the recyclerview – Shikha Ratra Aug 17 '16 at 07:06
-
Nope, its complicated, its the view of another activity where only surface will be given to me. I am using Tv Input Framework. But I am using exoplayer for drawing over surface – Prasanna Sundar Aug 17 '16 at 07:07
-
@PrasannaSundar oh!! ok get the reference from the exoplayer latest lib. i used that to solve my problem..gud luck.. – Shikha Ratra Aug 17 '16 at 07:09
-
@ShikhaRatra Please share the code , I am also facing the same problem – Amit Verma Apr 13 '20 at 10:43
2 Answers
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