1
次のコードを使用して、使用可能な出力を検出していますが、接続されているBluetoothデバイスが認識されません。私はそれから音楽を演奏しているので、私のBluetoothデバイスが正しく接続されていることを知っています。AVAudioSessionが接続されたBluetoothデバイスを検出していません
let session = AVAudioSession.sharedInstance()
for description in session.currentRoute.outputs {
if description.portType == AVAudioSessionPortHeadphones {
NSLog("headphone plugged in")
let alertActin = UIAlertAction(title: "Headphones", style: UIAlertActionStyle.default, handler:nil)
alertActin.setValue(UIColor.blue, forKey: "titleTextColor")
alert.addAction(alertActin)
} else if description.portType == AVAudioSessionPortBluetoothA2DP {
NSLog("Bluetooth plugged in")
let alertActin = UIAlertAction(title: description.portName, style: UIAlertActionStyle.default, handler:nil)
alertActin.setValue(UIColor.blue, forKey: "titleTextColor")
alert.addAction(alertActin)
} else if description.portType == AVAudioSessionPortBluetoothLE {
NSLog("Bluetooth plugged in")
let alertActin = UIAlertAction(title: description.portName, style: UIAlertActionStyle.default, handler:nil)
alertActin.setValue(UIColor.blue, forKey: "titleTextColor")
alert.addAction(alertActin)
}
else {
NSLog("")
}
}
は、私は私のコードにこれを追加私のBluetoothスピーカーはまだやるが表示されない{ \t \t \t session.setCategory(とAVAudioSessionCategoryPlayAndRecord、:[.allowBluetooth])をしてみてください \t \t \tしてみてくださいsession.setActive(真) \t \t}キャッチ{ \t \t \t致命( "エラーがセットアップオーディオセッション") \t \t} – user1079052