0

I'm trying to build a tiny macOS App with Swift. Now I have some trouble on how to determine when a headphone or bluetooth headset is plugged in or connected to a Mac.

Any suggestions would be appreciated.

Update: I found an answer (posted as bellowing), but it's written with Objective-C. Anyone can help to convert it to Swift? (I tried, but got too much errors)

Vincent
  • 486
  • 6
  • 20
  • There is a solution for Objective C. https://stackoverflow.com/questions/5893244/how-to-detect-something-in-headphone-jack-on-a-mac?noredirect=1&lq=1 I used that in an app of mine – chronikum Sep 03 '18 at 18:48
  • Use AVCaptureSession. – El Tomato Sep 03 '18 at 20:12
  • @chronikum Thanks, man. I did check this link before asking for help. But it seems that AVAudioSession is (currently) only available for iOS, but not for macOS. https://developer.apple.com/documentation/avfoundation/avaudiosession – Vincent Sep 04 '18 at 02:27
  • @El Tomato Hi El, could you please share more details? It seems AVCaptureSeesion is used to perform a real-time or offline capture. – Vincent Sep 04 '18 at 03:23

0 Answers0