阅读(4924) (2)

百度智能小程序 ARCameraContext

2020-08-13 16:06:06 更新

ARCameraContext

解释:swan.createARCameraContext 的返回值。

属性说明

属性名 说明
ARCameraContext.startRecord 开始录像
ARCameraContext.stopRecord 结束录像
ARCameraContext.reset 重置相机
ARCameraContext.takePhoto 拍照

示例 

在开发者工具中打开



图片示例

代码示例

Page({
    data: {
        src: ''
    },
    onShow() {
        const cameraContext = swan.createCameraContext();
        this.cameraContext = cameraContext
        swan.showModal({
            title: '这是ARCameraContext创建的实例对象',
            content: JSON.stringify(cameraContext)
        })
    },
    takePhoto() {
        this.cameraContext.takePhoto({
            quality: 'high',
            success: res => {
                this.setData({
                    src: res.tempImagePath
                });
            }
        });
    },
    startRecord() {
        this.cameraContext.startRecord({
            success: res => {
                swan.showToast({
                    title: 'startRecord'
                });
            }
        });
    },
    stopRecord() {
        this.cameraContext.stopRecord({
            success: res => {
                swan.showModal({
                    title: '提示',
                    content: res.tempVideoPath
                });
                this.setData({
                    videoSrc: res.tempVideoPath
                });
            }
        });
    }
});