后浪云百度小程序教程:ARCameraContext

  • ARCameraContext
    • 示例
      • 图片示例
      • 代码示例

    ARCameraContext

    解释:swan.createARCameraContext 的返回值。
    Web 态说明:Web 态暂不支持 ar-camera 功能。在 Web 态调用 ARCameraContext 的各方法会做 打开百度 App 对应小程序页面 的降级处理。

    示例

    跳转编辑工具

    在开发者工具中打开

    在 WEB IDE 中打开

    扫码体验

    代码示例

    后浪云百度小程序教程:ARCameraContext插图

    请使用百度APP扫码

    图片示例

    后浪云百度小程序教程:ARCameraContext插图1

    代码示例

    • JS
     
     
     
    1. Page({
    2. data: {
    3. src: ''
    4. },
    5. onShow() {
    6. const cameraContext = swan.createCameraContext();
    7. this.cameraContext = cameraContext
    8. swan.showModal({
    9. title: '这是ARCameraContext创建的实例对象',
    10. content: JSON.stringify(cameraContext)
    11. })
    12. },
    13. takePhoto() {
    14. this.cameraContext.takePhoto({
    15. quality: 'high',
    16. success: res => {
    17. this.setData({
    18. src: res.tempImagePath
    19. });
    20. }
    21. });
    22. },
    23. startRecord() {
    24. this.cameraContext.startRecord({
    25. success: res => {
    26. swan.showToast({
    27. title: 'startRecord'
    28. });
    29. }
    30. });
    31. },
    32. stopRecord() {
    33. this.cameraContext.stopRecord({
    34. success: res => {
    35. swan.showModal({
    36. title: '提示',
    37. content: res.tempVideoPath
    38. });
    39. this.setData({
    40. videoSrc: res.tempVideoPath
    41. });
    42. }
    43. });
    44. }
    45. });
    THE END