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 ...
随机推荐
- nyoj 题目21 三个水杯
三个水杯 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 给出三个水杯,大小不一,并且只有最大的水杯的水是装满的,其余两个为空杯子.三个水杯之间相互倒水,并且水杯没有 ...
- Python中的多线程编程,线程安全与锁(一)
1. 多线程编程与线程安全相关重要概念 在我的上篇博文 聊聊Python中的GIL 中,我们熟悉了几个特别重要的概念:GIL,线程,进程, 线程安全,原子操作. 以下是简单回顾,详细介绍请直接看聊聊P ...
- 【bzoj5047】空间传送装置 堆优化Dijkstra
题目描述 n个点e条边的有向图,每条边是m种类型之一.第i种类型在第x时刻通过所花费的时间为$(a_i*x+b_i)\mod c_i+d_i$.可以在某个点停留.问:在s时刻从1号点出发,到达每个点所 ...
- thinkPHP判断是否修改成功
thinkPHP中使用save方法来更新数据的save方法的正常执行时返回值是影响的记录数,出错时返回false,返回为0和返回false在很多业务场景下都是不同的. 而当修改的内容和原有内容一致的时 ...
- poj 2367 拓扑排序入门
Description The system of Martians' blood relations is confusing enough. Actually, Martians bud when ...
- bigdecimal的使用
BigDecimal 由任意精度的整数非标度值 和 32 位的整数标度 (scale) 组成.如果为零或正数,则标度是小数点后的位数.如果为负数,则将该数的非标度值乘以 10 的负 scale 次幂. ...
- Android自复制传播APP原理学习(翻译)
Android自复制传播APP原理学习(翻译) 1 背景介绍 论文链接:http://arxiv.org/abs/1511.00444 项目地址:https://github.com/Tribler ...
- MFC 在窗口上画指定大小的ICON
CPaintDC dc(this); HICON hIcon = (HICON)::LoadImage(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_ICON) ...
- 总结各种width,height,top,left
1.offsetWidth 内容+内边距(padding)+边框(border) 2.offsetHeight 内容+内边距(padding)+边框(border) 3.offsetLeft 获取对象 ...
- Linux/unix inode
一.inode是什么? 理解inode,要从文件储存说起. 文件储存在硬盘上,硬盘的最小存储单位叫做"扇区"(Sector).每个扇区储存512字节(相当于0.5KB). 操作系统 ...