在Exoplayer的最新版本中,exoplayer.setThrowsWhenUsingWrongThread(false)
是被弃用的,有什么替代方法吗?因为当我删除它时,它会给出,
java.lang.IllegalStateException: Player is accessed on the wrong thread.
Current thread: 'DefaultDispatcher-worker-1
Expected thread: 'main'
如果我使用它,系外播放器工作得很好,但它是不推荐的。谢谢你的帮助!
发布于 2021-06-09 02:25:18
根据官方的setThrowsWhenUsingWrongThread()
,文档已经被废弃了,原因如下:"Disabling the enforcement can result in hard-to-detect bugs. Do not use this method except to ease the transition while wrong thread access problems are fixed."
,官方的发布说明在这个评论中通过提到方法将在下一个主要版本中被完全删除。
除了遵从库的严格的单线程范例之外,别无选择。请参阅Hello的关于线程处理的说明和官方文档的线程模型部分。您可以同时使用setThrowsWhenUsingWrongThread(false)
,因为它只是不推荐的,但是如果您想要利用即将出现的特性,就需要遵守它。
https://stackoverflow.com/questions/67895849
复制相似问题