【Objective-C】AVAudioSessionの音が Bluetoothイヤホンから流れない

概要

前回の「AVAudioSessionのPlayAndRecordで音量が小さくなる」に関連する内容で、Bluetoothイヤホン(AirPodsなど)から音が出ないときの対処方法です。

このページはswift4.2のコードを使用しています。

対応方法

setCategoryの指定に「.allowBluetoothA2DP」を追加することで解決します。

let session = AVAudioSession.sharedInstance()
do {
    try session.setCategory(AVAudioSession.Category.playAndRecord, mode: .default, options: [.defaultToSpeaker, .allowBluetoothA2DP])
    try session.setActive(true)
} catch let error {}
   

コメントを残す


CAPTCHA