I have an Exoplayer view in a fragment, when I animate the fragment container view from the activity the exo player will become black.
I used setKeepContentOnPlayerReset(true);
to keep the last frame and it's working fine.
But when I call the animate (sliding animation) on fragment container view (that's a Frame Layout) after the video is over, Exo player will display the black screen. (even the fragment exit transition also creates the same issue on Exo player, this time I didn't replaced the fragment just animated the container view, the issue is still present)
I haven't any clue related to this issue, It would be very helpful if anyone can share some idea related to this. welcomes every suggestion and answers related to this. Thank you.
It's turned out that using "texture_view
" for "app:surface_type
" will resolve the issue, This will make the Exo player use texture view instead of the surface view and that makes animations and scrolling smooth.
In documentation its says
On earlier releases, this could result in unwanted effects when a SurfaceView was placed into a scrolling container, or when it was subjected to animation. Such effects included the SurfaceView’s contents appearing to lag slightly behind where it should be displayed, and the view turning black when subjected to animation
In xml file, we can enable texture view as follows
<com.google.android.exoplayer2.ui.SimpleExoPlayerView
android:id="@+id/playerView"
android:layout_width="match_parent"
android:layout_height="200dp"
app:surface_type="texture_view"/>