【问题标题】:Issue with Opentok and CallKitOpentok 和 CallKit 的问题
【发布时间】:2018-05-24 06:36:20
【问题描述】:
【问题讨论】:
标签:
ios
swift
opentok
callkit
【解决方案1】:
你是如何发布你的流的?
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)
【解决方案2】:
我需要通过设置 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))
}