Android录制视频报错setVideoSize called in a invalid state 1
录制视频时想获取手机支持的录制视频的分辨率,使用代码如下:
List<Camera.Size> videoSize = camera.getParameters().getSupportedVideoSizes();
Iterator<Camera.Size> itos = videoSize.iterator();
while (itos.hasNext()) {
Camera.Size curSize = itos.next();
int curSupporSize = curSize.width * curSize.height;
int fixPictrueSize = setFixPictureWidth * setFixPictureHeight;
if (curSupporSize > fixPictrueSize) {
setFixPictureWidth = curSize.width;
setFixPictureHeight = curSize.height;
}
}
mediaRecorder.setVideoSize(setFixPictureWidth,
setFixPictureHeight);
出现了两次错误,一次是录制视频时调用camera.getParameters()时报parameters is empty
,这是由于在camera.unlock()之后调用了该函数,将其在unlock之前获取就ok了。
还有一个错误就是setVideoSize called in a invalid state 1
,进入setVideoSize函数中可以发现抛出异常的条件说明
/**
* Sets the width and height of the video to be captured. Must be called
* after setVideoSource(). Call this after setOutFormat() but before
* prepare().
*
* @param width the width of the video to be captured
* @param height the height of the video to be captured
* @throws IllegalStateException if it is called after
* prepare() or before setOutputFormat()
*/
public native void setVideoSize(int width, int height)
throws IllegalStateException;
IllegalStateException if it is called after prepare() or before setOutputFormat()
表示如果setVideoSize在prepare() 之后或者setOutputFormat()之前调用的话就会出现该异常,即是说要求setVideoSize函数在prepare()之前以及setOutputFormat()之后调用。
查了下代码,发现我调用setVideoSize竟然是在setOutputFormat()之前,改到setOutputFormat()之后就ok了。
Android录制视频报错setVideoSize called in a invalid state 1的更多相关文章
- MediaPlayer 播放assets 文件夹下面的视频报错
Android MediaPlayer 播放assets 文件夹下面的视频报错 报下面的错: java.io.FileNotFoundException: This file can not be o ...
- android sdk启动报错error: could not install *smartsocket* listener: cannot bind to 127.0.0.1:5037:
android sdk启动报错error: could not install *smartsocket* listener: cannot bind to 127.0.0.1:5037: 问题原因: ...
- react native-调用react-native-fs插件时,如果数据的接口是需要验证信息的,在android上运行报错
调用react-native-fs插件时,如果数据的接口是需要验证信息的,在android上运行报错,而在iOS上运行没问题.原因是因为接口是有验证信息的,而调用这个插件时没有传入,在iOS上会自动加 ...
- 解决Android Studio Conflict with dependency 'com.android.support:support-annotations'报错
解决Android Studio Conflict with dependency 'com.android.support:support-annotations'报错 在Android Studi ...
- sqlplus 连接数据库报错SP2-0642: SQL*Plus internal error state 2130, context 0:0:0
sqlplus 连接数据库报错SP2-0642: SQL*Plus internal error state 2130, context 0:0:0 问题描述: 使用sqlplus客户端登录数据库,报 ...
- 运行报错:java.io.IOException: invalid constant type: 15
jdk,tomcat更新到jdk1.8与 tomcat8 运行报错:java.io.IOException: invalid constant type: 15 pom.xml文件中更新javassi ...
- Poi读取Excle报错 java.util.zip.ZipException: invalid stored block lengths
一:Poi读取Excle报错 java.util.zip.ZipException: invalid stored block lengths 系统中需要导出excle签收单,excle模板是预设好 ...
- JavaWeb报错:java.sql.SQLException: Invalid value for getInt()
1.错误描述:在对数据库进行操作时,控制台报错:java.sql.SQLException: Invalid value for getInt() :2.错误原因:数据库中表的字段的类型与实体类中属性 ...
- spark提交任务报错: java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
spark提交任务报错: java.lang.SecurityException: Invalid signature file digest for Manifest main attributes ...
随机推荐
- UVALive 4764 简单dp水题(也可以暴力求解)
B - Bing it Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status ...
- FileZilla修改文件大小格式
之前使用FileZilla觉得很奇怪,文件大小显示为字节格式,很不习惯. 最近发现是在这里修改. 菜单“编辑”下选择设置,选择选项“文件大小格式”,在右边选择为:“使用SI式二进制前缀.(如 1 KB ...
- tomcat调优(Mark)
http://blog.csdn.net/jinwanmeng/article/details/7756591
- 【bzoj1007】[HNOI2008]水平可见直线 半平面交/单调栈
题目描述 在xoy直角坐标平面上有n条直线L1,L2,...Ln,若在y值为正无穷大处往下看,能见到Li的某个子线段,则称Li为可见的,否则Li为被覆盖的.例如,对于直线:L1:y=x; L2:y=- ...
- [poj] 1389 Area of Simple Polygons
原题 线段树+扫描线 对于这样一个不规则图形,我们要求他的面积有两种方法,割和补. 补显然不行,因为补完你需要求补上去的内部分不规则图形面积-- 那么怎么割呢? 像这样: 我们就转化成了无数个矩形的和 ...
- jquery defered的progress方法实现进度条
效果如图: 实现代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset=&qu ...
- AE中实现Control中的各种图形工具的方法
添加命名空间 using ESRI.ArcGIS.SystemUI;using ESRI.ArcGIS.Controls; A类:前面有Controls 后面有tool的工具都可以用同一类的代码实现( ...
- 2016华中农业大学预赛 B 数学
Problem B: Handing Out Candies Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 272 Solved: 20[Submit ...
- 【 D3.js 进阶系列 — 4.0 】 绘制箭头
转自:http://www.ourd3js.com/wordpress/?p=660 [ D3.js 进阶系列 — 4.0 ] 绘制箭头 发表于2014/12/08 在 SVG 绘制区域中作图,在绘制 ...
- CSS Sprites技术
CSS Sprites技术,国内很多人也叫雪碧图,因为sprite麻 (你买一瓶雪碧就看得到大大的sprite字样了) 主要用于将网站的零碎图标的img标签取代,因为每个img标签引用的src就会造成 ...