Check if android device support 4K video?

倾然丶 夕夏残阳落幕 提交于 2019-12-30 08:19:06

问题


I am trying to play a 4K video in my application, but as long as all devices can not play 4K videos I'm having some troubles.

  • How can I check at runtime if that device support it or not before playing the video?

回答1:


First of all, you have to remember 4k is just a resolution, but you have to also remember about bitrate.

Here's a method to test whether resolution/bitrate combination is achievable on a certain device:

boolean areSizeAndRateSupported (int width, int height, double frameRate)

https://developer.android.com/reference/android/media/MediaCodecInfo.VideoCapabilities.html#areSizeAndRateSupported(int,%20int,%20double)

There's also:

isSizeSupported(int width, int height)

The only downside of these methods is that it's supported from API level 21.

You can also check codec capabilities using this method:

MediaCodecInfo.VideoCapabilities.getVideoCapabilities()

https://developer.android.com/reference/android/media/MediaCodecInfo.CodecCapabilities.html#getVideoCapabilities()

But as far as I know, they can return lower resolution than actually supported.

From the other hand, in your case, devices below android lollipop most likely aren't fast enough to play 4k video. Or even if they can, their resolution is too low to actually get any benefit from 4k resolution.

So, in my opinion, the most elegant solution is to assume 4k is not supported below android 5.0 and use a method from above check whether it's supported on android 5.0+.



来源:https://stackoverflow.com/questions/30844734/check-if-android-device-support-4k-video

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!