Options
All
  • Public
  • Public/Protected
  • All
Menu

Module media_projection

This module can request screen capture permission, get screen capture and listen screen capture events.

see

Image

Index

Functions

requestScreenCapture

  • Request for screen capturing, and return a Promise of ScreenCapturer. If user rejects or encounters an error, it will throw a ScreenCaptureRequestError.

    Request for screen capturing needs to start a new Activity, so that on Android 10 and higher, only the app is in the foreground can request. And the app must keep the foreground service running while capturing, otherwise it will not receive new images.

    example
    "nodejs";
    const { requestScreenCapture } = require("media_projection");
    
    async function main() {
      const capturer = await requestScreenCapture();
      const img = await capturer.nextImage();
      console.log(img);
    }
    main();
    

    Parameters

    • Optional options: ScreenCaptureOptions

      Screen capturing options

    • Optional context: android.content.Context

      Context for starting the request for screen capturing, usually no need to pass this parameter

    Returns Promise<ScreenCapturer>