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

  • CameraContext
    • 示例
      • 图片示例
      • 代码示例

    CameraContext

    解释:swan.createCameraContext 的返回值。
    Web 态说明:Web 态暂不支持相机功能。调用 CameraContext 相关方法,在 Web 态会做 打开百度 App 对应小程序页面 的降级处理。

    示例

    跳转编辑工具

    在开发者工具中打开

    在 WEB IDE 中打开

    扫码体验

    代码示例

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

    请使用百度APP扫码

    图片示例

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

    代码示例

    • SWAN
    • JS
     
     
     
    1. <view class="wrap">
    2. <view class="card-area">
    3. <camera
    4. device-position="{{device}}"
    5. flash="off"
    6. bindstop="stop"
    7. binderror="error"
    8. class="preview"
    9. style="width: 100%; height: 3rem;">
    10. </camera>
    11. <button type="primary" bind:tap="switchCamera">切换摄像头</button>
    12. <button type="primary" bind:tap="takePhoto">拍照</button>
    13. <button type="primary" bind:tap="startRecord">开始录像</button>
    14. <button type="primary" bind:tap="stopRecord">结束录像</button>
    15. <view class="preview">预览</view>
    16. <image s-if="imageSrc" class="image" mode="widthFix" src="{{imageSrc}}"></image>
    17. <video s-if="videoSrc" class="video" src="{{videoSrc}}"></video>
    18. </view>
    19. </view>
    THE END