本文介绍了检查android设备是否支持4K视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的应用程序中播放4K视频,但只要所有设备都无法播放4K视频,我就会遇到麻烦。

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.


  • 在播放视频之前,如何在运行时检查该设备是否支持该设备?

推荐答案

首先,你必须记住4k只是一个分辨率,但你还要记住比特率。

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)

那里s还:

isSizeSupported(int width, int height)

这些方法的唯一缺点是API级别21支持它。

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()

但就我而言知道,他们可以返回低于实际支持的分辨率。

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

另一方面,在你的情况下,android lollipop以下的设备很可能不足以播放4k视频。或者即使它们可以,它们的分辨率太低而无法从4k分辨率中获得任何好处。

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.

因此,在我看来,最优雅的解决方案是假设4k是在Android 5.0下面不支持并使用上面的方法检查它是否在Android 5.0 +上受支持。

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+.

这篇关于检查android设备是否支持4K视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-22 07:53