🎧Define if headphones is only playing device for current session

I need to apply headphone-specific scenario only when headphones are the sole active playback device in my iOS audio app.

Problem that there is no absolute way to definitively understand that headphones are the sole active playback device

AVAudioSession.currentRoute.outputs portTypes don't guarantee headphones:

let session = AVAudioSession.sharedInstance()
let outputs = session.currentRoute.outputs
let headphonesOnly = outputs.count == 1 && 
    (outputs.first?.portType == .headphones ||
     outputs.first?.portType == .bluetoothA2DP ||
     outputs.first?.portType == .bluetoothHFP ||
     outputs.first?.portType == .bluetoothLE)

The issue in code above that listed bluetooth profiles (A2DP, HFP, LE) can be used by any audio device, not only headphones

Is there any public API on iOS that can:

  1. Distinguish Bluetooth headphones vs Bluetooth speakers when both use A2DP/LE?

  2. Expose the user’s “Device Type” classification (headphones / speaker / car stereo, etc.) that is shown in Settings → Bluetooth → Device Type?

  3. Provide a more reliable way to know “this route is definitely headphones” for A2DP devices, beyond portType and portName string heuristics?

Hi there, unfortunately this is not currently possible to determine unambiguously from our audio APIs. Please do file an enhancement request via Feedback Assistant to track this proposal, additional details on filing that can be found here: https://developer.apple.com/forums/thread/712889 Thanks!

🎧Define if headphones is only playing device for current session
 
 
Q