when I use exoplayer
I get a player is accessed on the wrong thread error
. How can I solve this?
Non-fatal Exception: java.lang.IllegalStateException: Player is accessed on the wrong
thread.
Current thread: 'main'
Expected thread: 'ConnectivityThread'
See https://exoplayer.dev/issues/player-accessed-on-wrong-thread
The player is started as a service via my BackgroundAudioService.class.
exoPlayer = new ExoPlayer.Builder(getApplicationContext()
.build();
In the main thread my looper is running, the
which updates the UI via exoplayer.getCurrentPosition()
.
public final Runnable updatePosition = new Runnable() {
@Override
public void run() {
position = BackgroundAudioService.getCurrentPostion();
}
}
myHandler.postDelayed(updatePosition, myHandlerSleep);
I don't know how to solve this problem (which occurs just sometimes), please help.
Thanks Alejandro