3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

iOS SkyWaySDKでビデオ通話 音声出力先変更

Posted at

##SkyWayを使用してビデオ通話するiOSアプリ
音声の出力が通話用スピーカーだったのを内蔵スピーカーに変更しました。

AVFoundationをインポートして
remoteAudioSpeakerを定義

    func remoteAudioSpeaker() {
        self.remoteStream?.setEnableAudioTrack(0, enable: true)
        DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
            // speaker
            do {
                try AVAudioSession.sharedInstance().setActive(true)
                try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord)
                try AVAudioSession.sharedInstance().overrideOutputAudioPort(AVAudioSessionPortOverride.speaker)
                self.remoteStream?.setEnableAudioTrack(0, enable: true)
            } catch {
                print("AVAudioSessionCategoryPlayAndRecord error")
            }
        }
    }

イベントストリームでremoteAudioSpeakerを呼び出し

        mediaConnection.on(SKWMediaConnectionEventEnum.MEDIACONNECTION_EVENT_STREAM, callback: { (obj) -> Void in
            self.remoteAudioSpeaker()
            if let msStream = obj as? SKWMediaStream{
                self.remoteStream = msStream
            }
        })

###注意点
STREAMのなかに直接書くのではなく、外部に書いて1秒遅れで出力先を設定すべし

3
3
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?