我正在集成Skype的iOS SDK,当我尝试从对话助手启动audioservice时。
do {
try self.conversationHelper.conversation.audioService.start()
}
catch {
print(error.localizedDescription)
}
我得到了这个错误。声音既没有传入也没有传出。(但视频服务运行正常。)
2016-11-12 21:22:00.012 test-skype[669:1aa91fc40] INFO APPLICATION CUcmpAudioModality.cpp:230 CUcmpAudioModality::start(AudioType) called.
2016-11-12 21:22:00.014 test-skype[669:1aa91fc40] INFO APPLICATION CUcmpAudioModality.cpp:259 CUcmpAudioModality::start(AudioType, CUriString) called.
2016-11-12 21:22:00.015 test-skype[669:1aa91fc40] INFO APPLICATION CUcmpAudioVideoModality.cpp:2799 CUcmpAudioModality::queryCapability on StartVoIP returned false because modality state is InConversation
2016-11-12 21:22:00.017 test-skype[669:1aa91fc40] ERROR APPLICATION CUcmpAudioModality.cpp:267 Unable to start audio with error (587726849)
如何解决这个问题?请帮助。
我设法找到一个解决方案。我需要初始化AVAudioSession
并首先将类别设置为AVAudioSessionCategoryPlayAndRecord
以使其工作。
let audioSession: AVAudioSession = AVAudioSession.sharedInstance()
do{
try audioSession.setCategory(AVAudioSessionCategoryPlayAndRecord)
}
catch let errorForCategory as Error{
print(errorForCategory.localizedDescription)
}
do{
try audioSession.setMode(AVAudioSessionModeVoiceChat)
}
catch let errorForMode as Error {
print(errorForMode.localizedDescription)
}
编辑:如果你计划在视频聊天中使用Airplay,你需要将模式设置为本文档中提到的AVAudioSessionModeVideoChat
。https://developer.apple.com/library/content/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/AudioSessionBasics/AudioSessionBasics.html
do {
try audioSession.setMode(AVAudioSessionModeVideoChat)
}
catch let errorForMode as Error {
print(errorForMode.localizedDescription)
}