PyObjC MediaExtension Framework

12.1 · active · verified Tue Apr 14

pyobjc-framework-mediaextension provides Python wrappers for the macOS MediaExtension framework, enabling developers to create extensions for media playback and editing on macOS. It is part of the larger PyObjC project, which bridges Python and the Objective-C runtime. The library is actively maintained with a regular release cadence, often tied to macOS SDK updates, with version 12.1 being the current stable release.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the MediaExtension framework and access one of its core classes. As MediaExtension is designed for implementing system extensions, a simple script can only verify the Python bindings are correctly installed and can access the underlying Objective-C framework components, rather than performing a full functional task without a host application context.

import MediaExtension
import objc

# The MediaExtension framework primarily deals with creating extensions
# for media playback and editing on macOS. Due to its nature, a simple
# script can only verify its presence and accessibility, not its full functionality
# which typically requires a host application context.

print('Attempting to import MediaExtension framework...')

try:
    # Accessing a fundamental class from the framework verifies the import.
    # MEMediaExtension is a key class. If the framework is correctly loaded,
    # this class should be accessible.
    media_extension_class = MediaExtension.MEMediaExtension
    print(f"Successfully imported MediaExtension and accessed its class: {media_extension_class}")

    # Further verification: Check for a common method (illustrative)
    if hasattr(media_extension_class, 'beginMediaExtensionProcessWithConfiguration:completionHandler:'):
        print("Found a common MediaExtension method, indicating bindings are functional.")
    else:
        print("Could not find a common MediaExtension method, though class is accessible.")

except objc.nosuchmodule_error:
    print("Error: MediaExtension framework not found. This typically means you are not on macOS,")
    print("      or the framework is not available for your macOS version.")
except AttributeError as e:
    print(f"Error accessing MediaExtension classes: {e}. Framework might be present but classes not exposed or wrong name.")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

print('Quickstart complete: Demonstrated successful import and class access for MediaExtension.')

view raw JSON →