exoplayer.setThrowsWhenUsingWrongThread(false) 已弃用

exoplayer.setThrowsWhenUsingWrongThread(false) is deprecated

exoplayer.setThrowsWhenUsingWrongThread(false) 在 Exoplayer 最新版本中 已弃用 ,是否有其他替代方案,因为当我删除它时它会给出,

java.lang.IllegalStateException: Player is accessed on the wrong thread.
Current thread: 'DefaultDispatcher-worker-1
Expected thread: 'main'

exoplayer 如果我使用它可以正常工作,但它已弃用。 感谢您的帮助!

setThrowsWhenUsingWrongThread() 根据官方 documentation: "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." The official release notes 由于以下原因而被弃用,通过提及该方法将在下一个主要版本中完全删除来扩展此评论。

除了遵守图书馆严格的单线程范例外别无选择。请参阅官方文档的 Hello World 的 note on threading and the threading model 部分。您可以同时使用 setThrowsWhenUsingWrongThread(false),因为它只是被弃用了,但如果您想使用即将推出的功能,则需要遵守。