Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
347 views
in Technique[技术] by (71.8m points)

java - InflateException with PlayerView Exoplayer after a lot of videos

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...