I have a similar feed to instagram. However, when I watched like 50 - 60 videos, it randomly crashes. Sometimes after 60, sometimes after 80, sometimes after 40.
Caused by android.view.InflateException: Binary XML file line #243 in com.flax.de:layout/fragment_categories: Error inflating class com.google.android.exoplayer2.ui.PlayerView
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
android:visibility="gone"
android:scaleType="fitCenter"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/playerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Code for starting the player
if (getContext() == null || mediaItem == null) return;
player = new SimpleExoPlayer.Builder(getContext()).build();
playerView.setPlayer(player);
player.seekTo(0);
player.setMediaItem(mediaItem);
player.prepare();
playerView.setVisibility(View.VISIBLE);
player.play();
imageView.setImageBitmap(null);
imageView.setImageResource(0);
imageView.setBackgroundColor(getContext().getResources().getColor(R.color.alwaysblack));
For finishing it
public void finishScene() {
if (player != null) player.release();
player = null;
playerView.setVisibility(View.GONE);
}
Any idea why it crashes? I always reset it when playing. So I have no idea...
Caused by android.content.res.Resources$NotFoundException
Unable to find resource ID #0x7f0800f4
question from:
https://stackoverflow.com/questions/65887461/inflateexception-with-playerview-exoplayer-after-a-lot-of-videos 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…