Registry / communication / pyobjc-framework-mediaplayer

pyobjc-framework-mediaplayer

JSON →
library12.2pypypiunverified

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-mediaplayer
INSTALL
IMPORT
SIG · PYOBJC-FRAMEWORK-M
P
pyobjc-framework-mediaplayer
communicationpythonv12.2
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MediaPlayer
import MediaPlayer
The framework is typically imported directly under its name.

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.

import MediaPlayer import time # This example attempts to play a system music item. # It requires user permission (Media & Apple Music access) and items in the Music library. # On a system without Music.app or items, this might not do much visibly. def play_music_item(): player = MediaPlayer.MPMusicPlayerController.systemMusicPlayer() print(f"Initial playback state: {player.playbackState()}") query = MediaPlayer.MPMediaQuery.songsQuery() items = query.items() if items and len(items) > 0: first_item = items[0] print(f"Attempting to play: {first_item.title()} by {first_item.artist()}") player.setQueueWithItemCollection_(MediaPlayer.MPMediaItemCollection.collectionWithItems_([first_item])) player.play() print("Playback started. You might need to check your Music.app or system volume.") time.sleep(5) player.pause() print("Playback paused after 5 seconds.") else: print("No music items found in the library or permissions not granted.") print("Please ensure Music.app has content and Python has access (System Settings > Privacy & Security > Media & Apple Music).") if __name__ == "__main__": print("This script will attempt to use macOS's MediaPlayer framework.") print("It requires an active macOS system with the Music.app and potentially music items.") print("You might be prompted for Media & Apple Music access by macOS.") play_music_item()
Debug
Known issues
breakingPyObjC 12.0 dropped support for Python 3.9. Ensure your environment uses Python 3.10 or newer.
fix
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.
affects: 12.0 and later
breakingPyObjC 11.1 changed how initializer methods are handled, aligning with clang's Automatic Reference Counting (ARC) documentation. Methods in the 'init' family now correctly 'steal' a reference to self and return a new one. This can affect memory management and object lifecycles if your code relied on the previous behavior.
fix
Review any custom Objective-C classes implemented in Python or complex object instantiation patterns for correct reference counting, especially around 'init' methods.
affects: 11.1 and later
gotchaPyObjC 10.3 introduced a change preventing `__init__` from being called when a user-implemented `__new__` was present in a class or its superclasses. This was partially reverted in 10.3.1 to re-enable `__init__` use when a user implements `__new__`, but still prohibits it when relying on PyObjC's provided `__new__`.
fix
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.
affects: 10.3, partially fixed in 10.3.1 and later
gotchaThe MediaPlayer framework on macOS requires specific user permissions (e.g., 'Media & Apple Music' access in System Settings > Privacy & Security). Your application might need to handle cases where these permissions are not granted, which can lead to silent failures or permission prompts.
fix
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.
affects: All versions (system-level requirement)
Upgrade
Version history
12.2latest on PyPI · released May 30, 2026
Audit
Dependencies
pyobjc-corerequiredProvides the core bridge between Python and Objective-C, essential for any PyObjC framework binding.
pythonrequiredRequires Python 3.10 or later as of PyObjC 12.x.
Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
pyobjc-framework-mediaplayer — pip install pyobjc-framework-mediaplayer · libregistry