Android getSupportedVideoSizes始终返回null [英] Android getSupportedVideoSizes always returns null

查看:86
本文介绍了Android getSupportedVideoSizes始终返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android上的MediaRecorder类上,我需要一些帮助.

I need some help with the MediaRecorder class on Android.

我尝试使用getSupportedVideoSizes来获取支持的视频尺寸列表,但它始终返回null.

I try to use getSupportedVideoSizes to get the list of supported video sizes, but it always returns null.

在测试中,查询getSupportedVideoSizes时,以下设备将返回null:

In testing, the following devices return null when getSupportedVideoSizes is queried:

  • Galaxy Nexus(Android 4.2)
  • HTC One Mini(Android 4.4.2)
  • HTCEVOV4G(Android 4.0.3)

推荐答案

Camera.getSupportedVideoSizes() 的文档,其内容为

The documentation for Camera.getSupportedVideoSizes() which reads,

返回
如果摄像机具有单独的预览和视频输出,则列出Size对象;否则,将返回null.

Returns
a list of Size object if camera has separate preview and video output; otherwise, null is returned.

尚不完全清楚.但是,这意味着如果Camera.getSupportedVideoSizes()返回null,则相机支持的预览尺寸和视频尺寸相同;反之,在这种情况下,要获取支持的视频尺寸列表,请使用Camera.getSupportedPreviewSizes().

is not entirely clear. However, it means that if Camera.getSupportedVideoSizes() returns null, then the camera's supported preview sizes and video sizes are the same; in this case, to get the list of supported video sizes, use Camera.getSupportedPreviewSizes().

示例代码:

public List<Size> getSupportedVideoSizes(Camera camera) {
    if (camera.getParameters().getSupportedVideoSizes() != null) {
        return camera.getParameters().getSupportedVideoSizes();
    } else {
        // Video sizes may be null, which indicates that all the supported 
        // preview sizes are supported for video recording.
        return camera.getParameters().getSupportedPreviewSizes();
    }
}

这篇关于Android getSupportedVideoSizes始终返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆