Код: Выделить всё
func configureAudioSession() {
let session = AVAudioSession.sharedInstance()
do {
try session.setCategory(.playAndRecord, options: [.mixWithOthers, .allowBluetoothA2DP, .defaultToSpeaker])
try session.setActive(true)
print("Session is active. Current route: \(session.currentRoute)")
if let bluetoothOutput = session.currentRoute.outputs.first(where: { $0.portType == .bluetoothA2DP }) {
print("Bluetooth A2DP device available: \(bluetoothOutput.portName)")
// Optionally prompt user or handle routing preferences
} else {
print("No Bluetooth A2DP route available; consider manual routing via Control Center.")
}
} catch {
print("Failed to configure audio session: \(error)")
}
}
- Я не хочу подключать AirPods к Apple TV
- Я попробовал приведенный выше код, но в итоге он перенаправил весь системный звук на AirPods /Устройство Встроенные динамики. Я этого не хочу. Вместо этого я хочу, чтобы системный звук продолжал транслироваться на Apple TV, пока мое приложение каким-то образом сможет отправлять звук на AirPods.
Подробнее здесь: https://stackoverflow.com/questions/792 ... o-apple-tv