This package provides Python wrappers for the macOS MediaPlayer framework, allowing Python applications to interact with system media services like accessing the user's music library and controlling playback. It is part of the larger PyObjC project, currently at version 12.1, with frequent updates tied to new macOS SDK releases and Python compatibility.
pip install pyobjc-framework-mediaplayerVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to interact with the macOS system music player using `pyobjc-framework-mediaplayer`. It attempts to find and play the first song in the user's Music library. Note that this requires macOS user permissions for 'Media & Apple Music' and actual music content in the Music.app.
Upgrade your Python interpreter to 3.10 or newer, or pin `pyobjc-framework-mediaplayer` to a version prior to 12.0 if you must use Python 3.9.
Review any custom Objective-C classes implemented in Python or complex object instantiation patterns for correct reference counting, especially around 'init' methods.
If experiencing issues with `__init__` and `__new__`, ensure your `__new__` implementation correctly handles object creation, and be aware that `__init__` might not be called in all scenarios where PyObjC provides the `__new__` method.
Inform users about required permissions and gracefully handle scenarios where access is denied. macOS will typically prompt the user for permission the first time your app attempts to access protected media.