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
Register a listener to receive events from the player. The listener's methods will be called on the thread that was used to construct the player. However, if the thread used to construct the player does not have a Looper, then the listener will be called on the main thread.
I did construct new SimpleExoPlayer instance within my own Looper (which is not Looper.mainLooper()). But when I call prepare() media source on main thread, ExoPlayer callback to all listeners within main thread instead of using my looper to dispatch the event.
I can see the method ExoPlayerImpl#updatePlaybackInfo invoke listener's methods within caller thread, regardless the thread was used to construct the player.
Reproduction steps
Create HandlerThread and then create ExoPlayer object within HandlerThread#onLooperPrepared
Add a listener: Player#addListener
Switch to main thread and call Player#prepare
Link to test content
Can test with demo app.
Version of ExoPlayer being used
2.8.0
The text was updated successfully, but these errors were encountered:
Khang-NT
changed the title
Events are not dispatched in correct Looper thread
EventListener isn't called in correct thread's looper
May 31, 2018
The documentation is not as clear as it should be, and based on the discussion in #4278, we also just changed it to spell out the requirements more explicitly.
Threading requirements were clarified in 2813c06. We'll also update the developer guide.
In addition, we're planning a change that will allow you to specify a Looper when instantiating the player, which will add a little more flexibility. Follow #4278 for updates.
Issue description
The document of method
Player#addListener
said:I did construct new SimpleExoPlayer instance within my own Looper (which is not
Looper.mainLooper()
). But when I callprepare()
media source on main thread,ExoPlayer
callback to all listeners within main thread instead of using my looper to dispatch the event.I can see the method
ExoPlayerImpl#updatePlaybackInfo
invoke listener's methods within caller thread, regardless the thread was used to construct the player.Reproduction steps
HandlerThread
and then createExoPlayer
object withinHandlerThread#onLooperPrepared
Player#addListener
Player#prepare
Link to test content
Can test with demo app.
Version of ExoPlayer being used
2.8.0
The text was updated successfully, but these errors were encountered: