Android ExoPlayer 2.18.1 以上版本出现: Unable to instantiate codec 'OMX.qcom.video.decoder.avc' with err 0xfffffff4.

yufei       2 年 前       1804

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)
}
目前尚无回复
简单教程 = 简单教程,简单编程
简单教程 是一个关于技术和学习的地方
现在注册
已注册用户请 登入
关于   |   FAQ   |   我们的愿景   |   广告投放   |  博客

  简单教程,简单编程 - IT 入门首选站

Copyright © 2013-2022 简单教程 twle.cn All Rights Reserved.