Android ExoPlayer 2.18.1 以上版本出现: Unable to instantiate codec 'OMX.qcom.video.decoder.avc' with err 0xfffffff4.
Android ExoPlayer 2.18.1 以上版本出现: Unable to instantiate codec 'OMX.qcom.video.decoder.avc' with err 0xfffffff4.
如果你用了其它方法还是报错,那么只有一个点,你的手机不支持硬件解码。ExoPlayer 默认关闭了硬件解码到软件解码之前的切换。所以,修复方式如下
Java
ExoPlayer.Builder builder = new ExoPlayer.Builder(getApplicationContext(), MediaSource.Factory.UNSUPPORTED); builder.setRenderersFactory(buildRenderersFactory(this,true)); ExoPlayer player = builder.build();
private RenderersFactory buildRenderersFactory(Context context , Boolean preferExtensionRenderer ) { int extensionRendererMode = DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON; if(preferExtensionRenderer) { extensionRendererMode = DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER; } return new DefaultRenderersFactory(context.getApplicationContext()) .setExtensionRendererMode(extensionRendererMode) .setEnableDecoderFallback(true); }
Kotlin
val builder : ExoPlayer.Builder = ExoPlayer.Builder(context); builder.setRenderersFactory(buildRenderersFactory(context.applicationContext,true)) val player = builder.build();
private fun buildRenderersFactory( context: Context, preferExtensionRenderer: Boolean ): RenderersFactory { val extensionRendererMode = if (preferExtensionRenderer) DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER else DefaultRenderersFactory.EXTENSION_RENDERER_MODE_ON return DefaultRenderersFactory(context.applicationContext) .setExtensionRendererMode(extensionRendererMode) .setEnableDecoderFallback(true) }
目前尚无回复