In System Information (or the command line equivalent: system_profiler) we can check if a display is built-in:
Displays:
Color LCD:
Display Type: LCD
Resolution: 1680 x 1050
Pixel Depth: 32-Bit Color (ARGB8888)
Main Display: Yes
Mirror: Off
Online: Yes
Built-In: Yes
What API should I use to check the same information? The app needs to disable playback when external display is connected. Note that HDCP isn't available on Mac therefore disabling it is the only way. (DRM stuff, which I hate).
Use the
CGDisplayIsBuiltin(_:)
method:which is part of Quartz Display Services:
References
CGDisplayIsBuiltin(_:) - Core Graphics | Apple Developer Documentation
Quartz Display Services - Core Graphics | Apple Developer Documentation
Quartz Display Services Programming Topics: Getting Information About Displays
GitHub - kfix/ddcctl: DDC monitor controls (brightness) for Mac OSX command line
GitHub - codykrieger/gfxCardStatus: gfxCardStatus is an open-source menu bar application that keeps track of which graphics card your unibody, dual-GPU MacBook Pro is using at any given time, and allows you to switch between them on demand.