-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Child threads will have problems releasing the player #8301
Comments
Multiple player list page slide releases can cause a lag |
Hi, it appears that your application has an issue releasing the player from a wrong thread, and you have found the documentation for this. It's not clear however what exactly is the issue you are facing. Can you please provide a more detailed explanation of the problem? |
Because viewPage2 here holds multiple players, it is obvious that the player is releasing the clip in the main thread when the page is turned, and the release of the child thread will prompt this error,Would like to ask what is a better way to release |
The player requires that all interactions with it happen on the same thread that the player was created. So, if you create the player instance on the main thread, then you need to interact with the player from the main thread. If you are using multiple players, an alternative is to move all the interactions with the player to another Looper thread. But, you need to create the player instances on that thread too. If you have multiple players too, maybe you can try to only call release() when the app is exiting, but not call release() while swiping? You can pause a player and then set a media item if you want to play a new video on a paused player. Overall, to properly structure an app with multiple players can become quite complicated, regarding your use-case. Issue #867 has a long comment thread with ideas how to properly handle similar scenarios, and two recent similar issues are #7947 and #8189 which you can look. I'm closing this for now, please feel free to re-open if none of the above information help you. |
So whether can't release normally
SimpleExoPlayer: Player is accessed on the wrong thread. See https://exoplayer.dev/issues/player-accessed-on-wrong-thread
java.lang.IllegalStateException
at com.google.android.exoplayer2.SimpleExoPlayer.verifyApplicationThread(SimpleExoPlayer.java:1531)
at com.google.android.exoplayer2.SimpleExoPlayer.release(SimpleExoPlayer.java:1293)
at com.dueeeke.videoplayer.exo.ExoMediaPlayer$2.run(ExoMediaPlayer.java:192)
The text was updated successfully, but these errors were encountered: