问题描述
在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,
尚不完全清楚.但是,这意味着如果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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!