ios - Sinch 不支持快速视频通话
问题描述
这是我的代码。我将此代码从目标 c 转换为 sinch 测试中的 swift` 提供 Objective-C 部分可能会有所帮助,但它不支持视频通话。当我接受通话音频工作正常。但视频没有发送到其他设备。如果有人有 swift 的示例代码,请帮助我,然后发送或尝试使用此代码修复它.. 谢谢
// MARK: - Load
override func viewDidLoad() {
super.viewDidLoad()
if call?.direction == SINCallDirection.incoming {
self.callStateLabel.text = ""
self.showButtons(EButtonsBar.kButtonsAnswerDecline)
//audioController().startPlayingSoundFile(path(forSound: "incoming.wav"), loop: true)
} else {
self.callStateLabel.text = "calling..."
self.showButtons(EButtonsBar.kButtonsHangup)
}
if (call?.details.isVideoOffered)! {
localVideoView.addSubview(videoController().localView())
localVideoFullscreenGestureRecognizer.require(toFail: switchCameraGestureRecognizer)
videoController().localView().addGestureRecognizer(localVideoFullscreenGestureRecognizer)
videoController().remoteView().addGestureRecognizer(remoteVideoFullscreenGestureRecognizer)
}
}
@IBAction func accept(sender: AnyObject) {
call?.answer()
}
@IBAction func decline(sender: AnyObject) {
call?.hangup()
dismiss(animated: true, completion: nil)
}
@IBAction func hangup(sender: AnyObject) {
call?.hangup()
dismiss(animated: true, completion: nil)
}
func audioController() -> SINAudioController{
return Global.client.audioController()
}
func videoController() -> SINVideoController {
return Global.client.videoController()
}
解决方案
在视图控制器中添加 2 个视图。一种用于本地视频查看,另一种用于远程视频视频。将其设置为查看控制器的插座。我有一个有效的音频呼叫示例,我只是将这些东西添加到我的呼叫视图控制器中。
func videoController() -> SINVideoController {
return appDeletgate.client.videoController()
}
在 viewdidload 中检查是否通过电话提供视频。
if call.details.isVideoOffered {
localVideoView.addSubview(videoController().localView())
//localVideoFullscreenGestureRecognizer.require(toFail: switchCameraGestureRecognizer)
//videoController().localView().addGestureRecognizer(localVideoFullscreenGestureRecognizer)
//videoController().remoteView().addGestureRecognizer(remoteVideoFullscreenGestureRecognizer)
}
添加此方法可在视图中添加远程视频。
func callDidAddVideoTrack(_ call: SINCall?) {
remoteVideoView.addSubview(videoController().remoteView())
}
还要确保将这 2 个键添加到 info.plist
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) need to access your camera for video call.</string>
<key>NSMicrophoneUsageDescription</key>
<string>$(PRODUCT_NAME) uses the Microphone for calling</string>
这就是我所说的。
let call: SINCall? = self.callClient().callUserVideo(withId: recipientName) //self.callClient().callUser(withId: recipientName)
let callVC = mainStoryBoard.instantiateViewController(withIdentifier: "CallVC") as! CallVC
callVC.call = call
self.navigationController?.pushViewController(callVC, animated: true)
推荐阅读
- c# - 在 VS2017 中检查与 Package Reference 相关的程序集
- c# - 循环遍历数据表选择数据 C#
- c# - 如何使用 C# 在 Clint Side Table 中删除/添加宽度?
- node.js - fs-stat 赋予价值 - Node.js
- php - 在 localhost 上的 Codeigniter 中实现忘记密码
- python - happybase 1.1.0 api 与 Hbase2.1.2 兼容吗?我遇到运输异常
- firebase - 如何在 Firestore 中为 whereEqualTo 查询计费?
- javascript - 如何在 Twilio 可编程聊天中收听来自多个频道的新消息?
- micronaut - 如何将 Bean 定义为“RestTemplate”?
- wordpress - 如何以折扣 > 2% 展示特价商品