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。
Properties Type Default value Required Description visualEffect string none No The performance when taking screenshots/recording, only supports none / hidden, passing in hidden means hiding the screen when taking screenshots/recording success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback 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。
Properties Type Default value Required Description value number - Yes Screen 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. success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback 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。
Properties Type Default value Required Description keepScreenOn boolean - Yes Whether to keep the screen always on success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure) Sample code:
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:
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
Properties Type Description state string Screen recording status, legal values
1.start: Start screen recording
2.stop: End screen recordingSample code:
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:
const handler = function (res) {
console.log(res.state)
}
wx.onScreenRecordingStateChanged(handler)
wx.offScreenRecordingStateChanged(handler)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。
Properties Type Default value Required Description success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure) object.success callback function parameters: Object res。
Properties Type Description state string Screen recording status, legal values
1.on: On
2.off: OffSample code:
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。
Properties Type Default value Required Description success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure) object.success callback function parameters: Object res。
Properties Type Description value number Screen brightness value, range 0 ~ 1, 0 is the darkest, 1 is the brightest