Skip to content

vap android库 对设备是否支持h265的判断有问题 #230

@gejiashu

Description

@gejiashu

在三星A5 Android 5.1.1上面无法播放,翻了下源码发现是判断不支持hevc格式
看了一下获取设备支持格式的代码,貌似是有问题的

private fun getSupportType() {
        try {
            val numCodecs = MediaCodecList.getCodecCount()
            for (i in 0 until numCodecs) {
                val codecInfo = MediaCodecList.getCodecInfoAt(i)
                if (!codecInfo.isEncoder) {
                    continue
                }
                val types = codecInfo.supportedTypes
                for (j in types.indices) {
                    supportTypeMap[types[j].toLowerCase()] = true
                }
            }
            ALog.i(TAG, "supportType=${supportTypeMap.keys}")
        } catch (t: Throwable) {
            ALog.e(TAG, "getSupportType $t")
        }
    }
if (!codecInfo.isEncoder) {
                    continue
 }

这行代码的判断应该是有问题的吧,应该是判断如果是编码器 才执行continue,如果是解码器接着执行。我测试的三星A5这台设备就是没有h265对应的编码器所以导致格式判断不通过,但是设备是有h265对应的解码器的。所以放开格式判断之后是能正常播放的。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions