【问题标题】:Issue with Opentok and CallKitOpentok 和 CallKit 的问题
【发布时间】:2018-05-24 06:36:20
【问题描述】:

我正在尝试使用 OpentokCallKit 进行音频和视频通话,我已按照 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之后,新的通话以Built-in-Speaker开始,并自动切换到Speaker,无法更改输出。

【问题讨论】:

    标签: 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))
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多