[英]Issue with Opentok and CallKit
I am trying to use Opentok
and CallKit
for audio and video calling purpose, I have followed this demo provided by OpenTok https://github.com/opentok/CallKit/tree/master/CallKitDemo 我正在尝试使用
Opentok
和CallKit
进行音频和视频通话,我已经按照OpenTok提供的这个演示了https://github.com/opentok/CallKit/tree/master/CallKitDemo
The issue I am facing is when I am doing audio call to another person it starts speaker instead of Built-in-Receiver. 我面临的问题是,当我向另一个人进行音频通话时,它会启动扬声器而不是内置接收器。 I tried their demo and it also has the same issue.
我尝试了他们的演示,它也有同样的问题。
Then I tried https://developer.apple.com/library/content/samplecode/Speakerbox/Introduction/Intro.html#//apple_ref/doc/uid/TP40017290 which is provided by Apple, but after implementing the AudioController
, the new call starts with Built-in-Speaker and it automatically switched to Speaker and there is no way to make output change. 然后我尝试了Apple提供的https://developer.apple.com/library/content/samplecode/Speakerbox/Introduction/Intro.html#//apple_ref/doc/uid/TP40017290 ,但是在实现
AudioController
,新的呼叫以内置扬声器开始,并自动切换到扬声器,无法进行输出更改。
How are you publishing your stream? 你是如何发布你的流的?
let settings = OTPublisherSettings()
settings.name = "\(userID)"
guard let publisher = OTPublisher(delegate: self, settings: settings)
else {
return
}
yourStream = publisher
yourStream?.publishAudio = false
yourStream?.publishVideo = true
var error: OTError?
session?.publish(publisher, error: &error)
guard error == nil else {
print(error!)
return
}
guard let publisherView = publisher.view else {
return
}
participantVideoView.addSubview(publisherView)
I need to implement a custom audio driver with setting up the AVAudioSession
我需要通过设置
AVAudioSession
来实现自定义音频驱动程序
var audioOptions: UInt {
if isSpeaker {
return AVAudioSessionCategoryOptions.defaultToSpeaker.rawValue |
AVAudioSessionCategoryOptions.mixWithOthers.rawValue |
AVAudioSessionCategoryOptions.allowBluetooth.rawValue |
AVAudioSessionCategoryOptions.allowAirPlay.rawValue
} else {
return AVAudioSessionCategoryOptions.mixWithOthers.rawValue |
AVAudioSessionCategoryOptions.allowBluetooth.rawValue |
AVAudioSessionCategoryOptions.allowAirPlay.rawValue |
AVAudioSessionCategoryOptions.duckOthers.rawValue
}
}
if isSpeaker {
try session.setCategory(AVAudioSessionCategoryPlayAndRecord, mode: AVAudioSessionModeVoiceChat, options: AVAudioSessionCategoryOptions(rawValue: audioOptions))
} else {
try session.setCategory(AVAudioSessionCategoryPlayAndRecord, mode: AVAudioSessionModeVoiceChat, options: AVAudioSessionCategoryOptions(rawValue: audioOptions))
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.