[英]Issue with Opentok and CallKit
我正在嘗試使用Opentok
和CallKit
進行音頻和視頻通話,我已經按照OpenTok提供的這個演示了https://github.com/opentok/CallKit/tree/master/CallKitDemo
我面臨的問題是,當我向另一個人進行音頻通話時,它會啟動揚聲器而不是內置接收器。 我嘗試了他們的演示,它也有同樣的問題。
然后我嘗試了Apple提供的https://developer.apple.com/library/content/samplecode/Speakerbox/Introduction/Intro.html#//apple_ref/doc/uid/TP40017290 ,但是在實現AudioController
,新的呼叫以內置揚聲器開始,並自動切換到揚聲器,無法進行輸出更改。
你是如何發布你的流的?
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)
我需要通過設置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.