You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use the latest Exoplayer2.17.0 in RecyclerView,some items play video normally,some items only have audio but no video on a black background area!!all other views of RecyclerView item are displayed correctly ,only the video play is wrong
my code is :
1、init exoplayer in fun onStart() :
val mPlayer = ExoPlayer.Builder(mActivity).build()
2、when scroll Recyclerview to PlayerView item :
holder.playView.player = mPlayer
val firstLocalMediaItem = MediaItem.fromUri(url)
mPlayer?.run {
clearMediaItems() // only one video to play
repeatMode = Player.REPEAT_MODE_ALL
addMediaItem(firstLocalMediaItem)
playWhenReady = true
prepare()
}
3、when PlayerView scroll out of screen,I stop the video that is playing
if (mPlayer?.isPlaying == true) {
mPlayer?.stop()
}
4,scroll RecyclerView,two listener
// scroll RecyclerView
recyclerView.addOnScrollListener(recyclerViewScrollListener)
// scroll PlayerView is out of screen
recyclerView.addOnChildAttachStateChangeListener(childAttachStateChangeListener)
my question:
1,My recyclerView has 2 itemType, there will be at most one PlayerView on the current screen , when I scroll to the first and second PlayerView , its playing normally , and when I scroll to the third PlayerView its just has audio , only the PlayerView is wrong in the third item, After that , one PlayerView item is normal , one PlayerView is only audio
2,What I am thinking is that the ViewHolder is being reused, but the ViewHolder for each item contains the correct content, except for the black screen when playing,There must be something wrong with my ExoPlayer operation which caused the black screen
Thank for your help
The text was updated successfully, but these errors were encountered:
Having a player in scrolling RecyclerView with a single or multiple players is an advanced topic for that we can't really provide you with support I'm afraid.
From what you report it looks like that the player is not released properly and then the number of available video decoder gets exceeded. Audio continues working with a software codec.
There is also #867 where people are discussion various options and details around the case of recycler view.
I'm closing as a duplicate of that issue. Please reopen if you think your case touches a specific library issue.
I read the introduce for this method setPlayer(@Nullable Player player)
To transition a Player from targeting one view to another, it's recommended to use
switchTargetView(Player, PlayerView, PlayerView) rather than this method. If you do wish to
use this method directly,
be sure to attach the player to the new view before calling setPlayer(null) to detach it from the old one.
This ordering is significantly more efficient and may allow for more seamless transitions
description
use the latest Exoplayer2.17.0 in RecyclerView,some items play video normally,some items only have audio but no video on a black background area!!all other views of RecyclerView item are displayed correctly ,only the video play is wrong
my code is :
my question:
1,My recyclerView has 2 itemType, there will be at most one PlayerView on the current screen , when I scroll to the first and second PlayerView , its playing normally , and when I scroll to the third PlayerView its just has audio , only the PlayerView is wrong in the third item, After that , one PlayerView item is normal , one PlayerView is only audio
2,What I am thinking is that the ViewHolder is being reused, but the ViewHolder for each item contains the correct content, except for the black screen when playing,There must be something wrong with my ExoPlayer operation which caused the black screen
Thank for your help
The text was updated successfully, but these errors were encountered: