pyobjc-framework-mediaaccessibility provides Python bindings for Apple's MediaAccessibility framework on macOS. It allows Python developers to interact with system-wide media accessibility settings, such as closed captions and audio descriptions. The library is part of the larger PyObjC project, which regularly releases updates, typically aligning with new macOS SDKs and Python versions. The current version is 12.1.
pip install pyobjc-framework-mediaaccessibilityVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import the MediaAccessibility framework and retrieve the currently selected caption language for the user domain using a standard C function binding.
Upgrade to Python 3.10 or later. For Python 3.9, the last supported version is PyObjC 11.1.
Review Python subclasses of Objective-C classes, particularly how `__init__` and `__new__` are implemented. Consider refactoring to use Objective-C designated initializers or explicitly managing `__new__` and `__init__` as per PyObjC's documentation.
When using PyObjC in a free-threaded Python environment, always assume Apple's frameworks are not thread-safe. Implement explicit locking (e.g., `threading.Lock`) around any calls to Objective-C APIs or access to Objective-C objects that might be shared or modified across multiple threads.
Ensure `pyobjc-core` is installed alongside any `pyobjc-framework-*` package, typically by installing `pyobjc` which pulls in `pyobjc-core` and common frameworks as dependencies, or by explicitly installing `pyobjc-core` first.
Only use `pyobjc-framework-mediaaccessibility` in macOS environments. For cross-platform applications, alternative accessibility libraries must be used.
Refer to Apple Developer documentation for the MediaAccessibility framework to understand the API details. PyObjC generally translates Objective-C naming conventions directly to Python (e.g., `MACaptionAppearanceCopySelectedLanguage` from C becomes `MediaAccessibility.MACaptionAppearanceCopySelectedLanguage` in Python).