-
Notifications
You must be signed in to change notification settings - Fork 271
cameraStat
sunjian880928 edited this page Jun 4, 2016
·
1 revision
配置好采集参数之后,通过kit类的startPreview和stopPreview方法启动预览。
kit类内部将预览画面作为subview,插入到 view 的最底层 需要访问摄像头和麦克风的权限,若授权失败,其他API都会拒绝服务。
采集相关的消息通知需要通过NSNotificationCenter注册 KSYCaptureStateDidChangeNotification来接收。 当收到采集状态变化的通知时,通过kit.captureState属性查询新的状态
状态名称 | 状态说明 |
---|---|
KSYCaptureStateIdle | 设备空闲中 |
KSYCaptureStateCapturing | 设备工作中 |
KSYCaptureStateDevAuthDenied | 设备授权被拒绝 |
KSYCaptureStateClosingCapture | 关闭采集设备中 |
KSYCaptureStateParameterError | 参数错误,无法打开(比如设置的分辨率,码率当前设备不支持) |
注册通知:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(onCaptureStateChange:)
name:KSYCaptureStateDidChangeNotification
object:nil];
响应事件:
- (void) onCaptureStateChange:(NSNotification *)notification {
if ( _kit.captureState == KSYCaptureStateIdle){
NSLog(@"idle");
}
else if (_kit.captureState == KSYCaptureStateCapturing ) {
NSLog(@"capturing");
}
else if (_kit.captureState == KSYCaptureStateClosingCapture ) {
NSLog(@"closing capture");
}
else if (_kit.captureState == KSYCaptureStateDevAuthDenied ) {
NSLog(@"camera/mic Authorization Denied");
}
else if (_kit.captureState == KSYCaptureStateParameterError ) {
NSLog(@"capture devices ParameterErro");
}
else if (_kit.captureState == KSYCaptureStateDevBusy ) {
NSLog(@"device busy, try later");
}
}
移除通知:
[[NSNotificationCenter defaultCenter] removeObserver:self
name:KSYCaptureStateDidChangeNotification
object:nil];