我在我的应用程序中使用 OpenTok SDK 进行视频通话。我需要在单击按钮时实现相机切换功能。但它不起作用。
我在用
@IBAction func cameraButtonAction(_ sender: Any) {
publisher?.cameraPosition = AVCaptureDevice.Position.back
}
点击按钮
连接会话时创建发布者
func sessionDidConnect(_ session: OTSession) {
print("The client connected to the OpenTok session.")
let settings = OTPublisherSettings()
settings.name = UIDevice.current.name
guard let publisher = OTPublisher(delegate: self, settings: settings) else {
return
}
var error: OTError?
session.publish(publisher, error: &error)
guard error == nil else {
print(error!)
return
}
guard let publisherView = publisher.view else {
return
}
let screenBounds = UIScreen.main.bounds
publisherView.frame = CGRect(x: screenBounds.width - 150 - 20, y: screenBounds.height - 150 - 20, width: 150, height: 150)
view.addSubview(publisherView)
}