OnLocalVideoInit 在什么时候调用
OnLocalVideoInit 没调用直接崩溃- -: unrecognized selector sent to instance 0x103c533c0Demo.VideoViewController OnLocalVideoInit:]: unrecognized selector sent to instance 0x103c533c0
您可以发下我们的日志来分析下,您函数调用顺序是否有问题,另外您可以先直接跑下我们的demo看看是否正常。另外您可以参考我们的demo,调用UserCameraControl打开视频,调用UserSpeakControl打开音频。执行此操作之后,会自动调用OnLocalVideoInit方法 没有什么分析日志
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-: unrecognized selector sent to instance 0x102c42d40'
*** First throw call stack:
(0x1844ab164 0x1836f4528 0x1844b8628 0x18de26188 0x1844b0b10 0x184395ccc 0x184ea72e4 0x18445377c 0x1844536fc 0x184452f84 0x184450b5c 0x184370c58 0x18621cf84 0x18dac95c4 0x100f22fa0 0x183e9056c)
libc++abi.dylib: terminating with uncaught exception of type NSException
我是对照你的demo写的,VideoViewController是复制你们的
func startVideoChat(_ userID: Int32) {
// 枚举本地视频采集设备
let videoDeviceArr = AnyChatPlatform.enumVideoCapture()
// 选择指定的视频采集设备
if videoDeviceArr!.count > 1 {
// 前置摄像头
AnyChatPlatform.selectVideoCapture(videoDeviceArr!.object(at: 1) as! String)
}
// 本地设置
AnyChatPlatform.setSDKOptionInt(BRAC_SO_LOCALVIDEO_OVERLAY, 1)
AnyChatPlatform.setSDKOptionInt(BRAC_SO_LOCALVIDEO_ORIENTATION, Int32(self.interfaceOrientation.rawValue))
// 采用 Overlay 模式
AnyChatPlatform.userSpeakControl(-1, true)
AnyChatPlatform.setVideoPos(-1, self, 0, 0, 0, 0)
AnyChatPlatform.userCameraControl(-1, true)
// 远程方设置
AnyChatPlatform.userSpeakControl(userID, true)
AnyChatPlatform.setVideoPos(userID, self.remoteVideoSurface, 0, 0, 0, 0)
AnyChatPlatform.userCameraControl(userID, true)
} OnLocalVideoInit您实现的这部分 代码是否不对,照着我们demo抄吧。另外您有没有写这个回调?建议您先调试我们demo跑跑debug下 关键这个OnLocalVideoInit方法没有走
//创建和初始化 AVCaptureVideoPreviewLayer 对象,实现本地视频的显示
func OnLocalVideoInit(_ session: AVCaptureSession) {
self.localCaptureLayer = AVCaptureVideoPreviewLayer(session: session)
self.localCaptureLayer!.frame = CGRect.init(x: 0, y: 0, width: 100, height: 130)
self.localCaptureLayer!.videoGravity = AVLayerVideoGravity.resizeAspectFill
self.localVideoView.layer.addSublayer(self.localCaptureLayer!)
}
请对比下我们的demo与您编写及相关引用之间的区别。:)
页:
[1]