- JS API 列表
- 基础
- 网络
- 媒体
- 地图
- 文件
- 开放接口
- 数据缓存
- 地理位置
- 设备
- 画布
- 界面
- 页面导航
- 侧边栏能力
- 行业开放
- AI/AR能力
- 第三方平台
- TTML
- 转发和挂载
- 其它
- 直播能力
EffectCameraStream.onError收藏我的收藏
收藏
我的收藏语法
Plain Text复制EffectCameraStream.onError(callback)
参数说明
function callback
回调参数
Object object
属性名 | 类型 | 说明 |
type | string | 生命周期事件类型,如 'request', 'play', 'stop' |
errMsg | string | 错误信息 |
代码示例
预期表现:连续点击【打开相机】,弹出错误提示。
html复制<button type="primary" bindtap="requestEffectCamera">打开相机</button>
js复制Page({
onShow: function (options) {
this.effectCameraStream = tt.createEffectCameraStream(this);
this.effectCameraStream.onError(this.onError);
this.effectCameraStream.onRequest(this.onRequest);
},
requestEffectCamera() {
this.effectCameraStream.request({
orientation: "front",
});
},
onError(error) {
console.log("onError", error);
const { type, errMsg } = error;
tt.showModal({
title: `onError ${type}`,
content: errMsg,
});
},
onRequest() {
tt.showModal({
title: "相机资源申请成功",
});
},
});
Bug & Tip
暂无。
点击纠错