EffectCameraStream.dispose收藏我的收藏
收藏
我的收藏语法
EffectCameraStream.dispose()
参数说明
无
返回值
无
代码示例
预期表现:依次点击【打开相机】-> 【释放相机资源】出现相机资源释放弹窗提示。
<button type="primary" bindtap="requestEffectCamera">打开相机</button> <button type="primary" bindtap="disposeEffectCamera">释放相机资源</button>
Page({ onShow: function () {}, requestEffectCamera() { this.effectCameraStream = tt.createEffectCameraStream(this); this.effectCameraStream.onError(this.onError); this.effectCameraStream.onRequest(this.onRequest); this.effectCameraStream.onPlay(this.onPlay); this.effectCameraStream.request({ orientation: "front", }); }, disposeEffectCamera() { if (this.effectCameraStream) { this.effectCameraStream.dispose(); this.effectCameraStream.offError(this.onError); this.effectCameraStream.offRequest(this.onRequest); this.effectCameraStream.offPlay(this.onPlay); this.effectCameraStream = null; tt.showToast({ title: "相机资源释放", }); } }, onError(error) { console.log("onError", error); const { type, errMsg } = error; tt.showModal({ title: `onError ${type}`, content: errMsg, }); }, onRequest() { console.log("相机资源申请成功"); this.effectCameraStream.play(); }, onPlay(cameraVideo) { tt.showToast({ title: "相机打开", }); console.log("相机数据", cameraVideo); }, });
Bug & Tip
暂无。