New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exoplayer black screen when scrolled through recyclerview #7750
Comments
@punitagoel2403 What surface type are you using? Is it a SurfaceView or TextureView? Also, what Android version you are using? |
@vikasgill I am not overriding any value. Just using the default basic structure. I am testing on Android 10. |
Thanks @vikasgill for hinting it out. On further exploration, I understood, I had to set the player in method onViewAttachedToWindow rather than onBind, since I am using singleton player object. It is working fine now. Thanks once again. :) |
I am reopening this issue. I just noticed there is another problem occurring after resolving the previously stated issue. For eg: I have 10 items in recyclerview. I have checked the holder position, it is correct, so selected view holder is correct. So, if one holder has played a video, next time it is not playing the video again, the video plays in previously newly used holder only. I also tested this with overriding onScrollStateChanged assuming it could be some recyclerview issue. But still the same results. Note: I am using singleton object of player. |
Any updates? |
@punitagoel2403 Could you please share what you are actually doing. I am in doubt you are setting the wrong surface instance. |
I am using singleton class for Exoplayer, and independent playerview for each item in a recyclerview. I am setting the player to playerview in onViewAttachedToWindow based on current position. Exoplayer.playVideo(false, null); // pauses the video, setPlayWhenReady(false) holder.playerView.setPlayer(Exoplayer.getPlayer()); // set the player to current holder playerview Exoplayer.playVideo(true, mMediaSourceMap.get(holder.getAdapterPosition())); // setPlayWhenReady(true) and prepare the player( player.prepare(mediaSource);) Media sources per url is prepared in advance This work fine, if I am scrolling to a holder used for the first time. But if I try to go back to the watched video, the player runs in last played playerview. Giving the example again I have checked the holder position, it is correct, so selected view holder is correct. Please let me know if you need more details. |
Closing. New similar issue raised in #8093 |
I am using exoplayer in recyclerview. It loads well if I click on independent video from the list, but if I swipe and move to previous or next video only audio is playing, and the video is black throughout the duration. Only first clicked video shows the display. It is surely not a loading problem, since I am using caching and even after caching it behaves same way.
Note: In rarest of occasions, it works fine for one swipe.
I am pausing previous and preparing n playing next video in onViewAttachedToWindow method
The text was updated successfully, but these errors were encountered: