PyObjC ReplayKit Framework

12.1 · active · verified Tue Apr 14

pyobjc-framework-replaykit provides Python bindings for Apple's ReplayKit framework on macOS, enabling developers to integrate screen recording and broadcasting capabilities into their Python applications. Part of the larger PyObjC project, it closely tracks macOS SDK updates, with current version 12.1. The PyObjC project generally releases new versions multiple times a year, often aligning with major macOS releases and Python version updates.

Warnings

Install

Imports

Quickstart

This example demonstrates how to check if ReplayKit is available for screen recording on the current macOS system. It sets up a minimal `PyObjCTools.AppHelper` event loop, which is often required for PyObjC applications interacting with Cocoa frameworks on the main thread. The `applicationDidFinishLaunching_` method, analogous to `AppDelegate` in Objective-C, is used to interact with the `ReplayKit.RPScreenRecorder` shared instance.

import ReplayKit
from PyObjCTools import AppHelper
from Foundation import NSObject, NSLog

class ReplayKitChecker(NSObject):
    def applicationDidFinishLaunching_(self, notification):
        # Access the shared screen recorder instance
        recorder = ReplayKit.RPScreenRecorder.sharedRecorder()

        # Check if ReplayKit is available for recording
        if recorder.isAvailable():
            NSLog("ReplayKit is available for screen recording.")
        else:
            NSLog("ReplayKit is not available for screen recording.")

        # In a real application, you'd perform further ReplayKit actions here
        # For this quickstart, we just check availability and then stop the application.
        AppHelper.stopEventLoop()

if __name__ == "__main__":
    # Run a minimal Cocoa event loop to execute the application delegate.
    # This is often necessary for PyObjC code interacting with UI frameworks.
    AppHelper.runEventLoop(argv=[], appDelegate=ReplayKitChecker.alloc().init())

view raw JSON →