Skip to content

Screen

setVisualEffectOnCapture

TIP

The API usage is as follows: wx.setVisualEffectOnCapture(Object object)
This API is supported by mini programs, but not by mini games.

  • Functional description: Set the screen performance when taking screenshots/recording, only supports calls on the Android side
  • Parameters and descriptions: Object object。
    PropertiesTypeDefault valueRequiredDescription
    visualEffectstringnoneNoThe performance when taking screenshots/recording, only supports none / hidden, passing in hidden means hiding the screen when taking screenshots/recording
    successFunction-NoCallback function for successful interface call
    failFunction-NoCallback function for failed interface call
    completeFunction-NoCallback function for interface call completion (executed regardless of success or failure)

setScreenBrightness

TIP

The API usage is as follows: wx.setScreenBrightness(Object object)

  • Functional description: Set screen brightness
  • Parameters and descriptions: Object object。
    PropertiesTypeDefault valueRequiredDescription
    valuenumber-YesScreen brightness value, range 0 ~ 1, 0 is darkest, 1 is brightest. On Android, a special value of -1 is supported, indicating that the screen brightness changes with the system.
    successFunction-NoCallback function for successful interface call
    failFunction-NoCallback function for failed interface call
    completeFunction-NoCallback function for interface call completion (executed regardless of success or failure)

setKeepScreenOn

TIP

The API usage is as follows: wx.setKeepScreenOn(Object object)

  • Functional description: Set whether to keep the screen always on. Only effective in the current applet, the setting will be invalid after leaving the applet

  • Parameters and descriptions: Object object。

    PropertiesTypeDefault valueRequiredDescription
    keepScreenOnboolean-YesWhether to keep the screen always on
    successFunction-NoCallback function for successful interface call
    failFunction-NoCallback function for failed interface call
    completeFunction-NoCallback function for interface call completion (executed regardless of success or failure)
  • Sample code:

js
wx.setKeepScreenOn({
  keepScreenOn: true
})

onUserCaptureScreen

TIP

The API usage is as follows: wx.onUserCaptureScreen(function listener)
This API is supported by mini programs, but not by mini games.

  • Functional description: Monitor user active screenshot events. Triggered when the user uses the system screenshot button to take a screenshot. Only one monitor can be registered

  • Parameters and descriptions: function listener。Monitor function for user active screenshot events

  • Sample code:

js
wx.onUserCaptureScreen(function (res) {
  console.log('user capture screen')
})

onScreenRecordingStateChanged

TIP

The API usage is as follows: wx.onScreenRecordingStateChanged(function listener)
This API is supported by mini programs, but not by mini games.

  • Functional description: Monitor user screen recording events

  • Parameters and descriptions: function listener。Monitor function for user screen recording events

    PropertiesTypeDescription
    statestringScreen recording status, legal values
    1.start: Start screen recording
    2.stop: End screen recording
  • Sample code:

js
const handler = function (res) {
  console.log(res.state)
}
wx.onScreenRecordingStateChanged(handler)

wx.offScreenRecordingStateChanged(handler)

offUserCaptureScreen

TIP

The API usage is as follows: wx.offUserCaptureScreen(function callback)
This API is supported by mini programs, but not by mini games.

  • Functional description: User active screenshot events. Cancel event monitoring
  • Parameters and descriptions: function listener。Callback function for user active screenshot events

offScreenRecordingStateChanged

TIP

The API usage is as follows: wx.offScreenRecordingStateChanged(function listener)
This API is supported by mini programs, but not by mini games.

  • Functional description: Remove the listener function for user recording events

  • Parameters and descriptions: function listener。Monitor function passed in by onScreenRecordingStateChanged. If this parameter is not passed, all monitor functions will be removed

  • Sample code:

js
const handler = function (res) {
  console.log(res.state)
}
wx.onScreenRecordingStateChanged(handler)

wx.offScreenRecordingStateChanged(handler)
js
const listener = function (res) { console.log(res) }

wx.onScreenRecordingStateChanged(listener)
wx.offScreenRecordingStateChanged(listener) // Pass the same function object used for listening.

getScreenRecordingState

TIP

The API usage is as follows: wx.getScreenRecordingState(Object object)
This API is supported by mini programs, but not by mini games.

  • Functional description: Query whether the user is recording the screen

  • Parameters and descriptions: Object object。

    PropertiesTypeDefault valueRequiredDescription
    successFunction-NoCallback function for successful interface call
    failFunction-NoCallback function for failed interface call
    completeFunction-NoCallback function for interface call completion (executed regardless of success or failure)
  • object.success callback function parameters: Object res。

    PropertiesTypeDescription
    statestringScreen recording status, legal values
    1.on: On
    2.off: Off
  • Sample code:

js
wx.getScreenRecordingState({
  success: function (res) {
    console.log(res.state)
  },
})

getScreenBrightness

TIP

The API usage is as follows: wx.getScreenBrightness(Object object)

TIP

If the automatic brightness adjustment function is turned on in the Android system settings, the screen brightness will be automatically adjusted according to the light. This interface can only obtain the value before the automatic brightness adjustment, not the real-time brightness value

  • Functional description: Get the screen brightness

  • Parameters and descriptions: Object object。

    PropertiesTypeDefault valueRequiredDescription
    successFunction-NoCallback function for successful interface call
    failFunction-NoCallback function for failed interface call
    completeFunction-NoCallback function for interface call completion (executed regardless of success or failure)
  • object.success callback function parameters: Object res。

    PropertiesTypeDescription
    valuenumberScreen brightness value, range 0 ~ 1, 0 is the darkest, 1 is the brightest