La captura de pantalla de iOS aún no se ha resuelto
Código de captura de pantalla de grabación de video de Android
Se puede escribir en onshow
// 安卓防止截屏录屏
if (/android/i.test(wx.getSystemInfoSync().system)&&wx.setVisualEffectOnCapture) {
wx.setVisualEffectOnCapture({
visualEffect: 'hidden',
complete: function (res) {
// wx.showToast({
// title: '成功',
// })
}
})
}
Pero cabe señalar que no sólo debes activar el monitoreo, sino también desinstalarlo.
onHide() {
// 页面隐藏和销毁时需要释放防截屏录屏设置
// 安卓
if (wx.setVisualEffectOnCapture) {
wx.setVisualEffectOnCapture({
visualEffect: 'none',
complete: function (res) {
}
})
}
},
onUnload() {
// 页面隐藏和销毁时需要释放防截屏录屏设置
if (wx.setVisualEffectOnCapture) {
wx.setVisualEffectOnCapture({
visualEffect: 'none',
complete: function (res) {
}
})
}
grabación anti-video de ios
onLoad(options) {
//跨屏幕防止ios录频
if (/ios/i.test(wx.getSystemInfoSync().system)&&wx.getScreenRecordingState) {
// res.state的值有两种情况 on(正在录屏) | off(没有开始录屏)
wx.getScreenRecordingState({
success: res => {
if (res.state != 'off') {
that.setData({
isShow: false//这里我对页面进行了遮挡处理
})
} else {
that.setData({
isShow: true
})
}
}
})
}
// 在当前页面点击录频
if (/ios/i.test(wx.getSystemInfoSync().system)&&wx.onScreenRecordingStateChanged) {
// res.state的值有两种情况 start(开始录屏) | stop(结束录屏)
wx.onScreenRecordingStateChanged(res => {
if (res.state == 'start') {
that.setData({
isShow: false//这里我对页面进行了遮挡处理
})
} else {
that.setData({
isShow: true
})
}
})
}
},
Por supuesto que tienes que desinstalarlo aquí también.
onHide() {
// 页面隐藏和销毁时需要释放防截屏录屏设置
// ios
if (wx.offScreenRecordingStateChanged) {
// 取消录屏监听事件
wx.offScreenRecordingStateChanged()
}
},
onUnload() {
// 页面隐藏和销毁时需要释放防截屏录屏设置
// ios
if (wx.offScreenRecordingStateChanged) {
// 取消录屏监听事件
wx.offScreenRecordingStateChanged()
}
},