你的浏览器禁用了JavaScript, 请开启后刷新浏览器获得更好的体验!
输入关键字进行搜索
搜索:
没有找到相关结果
暴风雨科技
xieyajie
- (AVCaptureDevice *)cameraWithPosition:(AVCaptureDevicePosition)position { _position = position; NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]; for ( AVCaptureDevice *device in devices ) if ( device.position == position ) return device; return nil; } - (void)swapFrontAndBackCameras { // Assume the session is already running NSArray *inputs = _session.inputs; for ( AVCaptureDeviceInput *input in inputs ) { AVCaptureDevice *device = input.device; if ( [device hasMediaType:AVMediaTypeVideo] ) { AVCaptureDevicePosition position = device.position; AVCaptureDevice *newCamera = nil; AVCaptureDeviceInput *newInput = nil; if (_position == AVCaptureDevicePositionFront) newCamera = [self cameraWithPosition:AVCaptureDevicePositionBack]; else newCamera = [self cameraWithPosition:AVCaptureDevicePositionFront]; newInput = [AVCaptureDeviceInput deviceInputWithDevice:newCamera error:nil]; // beginConfiguration ensures that pending changes are not applied immediately [_session beginConfiguration]; [_session removeInput:input]; [_session addInput:newInput]; // Changes take effect once the outermost commitConfiguration is invoked. [_session commitConfiguration]; break; } } }
尼古丁の眼涙
要回复问题请先登录或注册
3 个回复
暴风雨科技
环信封装之后,我们开发再来做这个事情,就非常困难了!
xieyajie
尼古丁の眼涙