调用CameraFrameListener.start()真机调试失败?
发布于 5 年前 作者 ming21 4374 次浏览 来自 问答

调用CameraFrameListener.start()真机调试失败,体验版以及预览可以调用,但在CameraContext.onCameraFrame()中只能获取宽高,data返回空对象。如图

荣耀10、荣耀8、小莫cc9Pro会出现以上问题。

iphone7调试会闪退。

.js文件
Page({
  takePhoto() {
    let self = this;
    const ctx = wx.createCameraContext()
    const listener = ctx.onCameraFrame((frame) => {
      console.log(frame.data,frame.width,frame.height)
      self.setData({
        text: JSON.stringify(frame)
      })
    });
    listener.start({
      success:(res) => {
        self.setData({
          ok: "成功"
        })
      },
      fail:(res) => {
        console.log(JSON.stringify(res))
        self.setData({
          ok:"失败"
        })
      }
    })
  },
  error(e) {
    console.log(e.detail)
  }
})

.wxml文件
<camera device-position="back" flash="off" binderror="error" style="width: 100%; height: 300px;" 
frame-size="medium"></camera>
<button type="primary" bindtap="takePhoto">拍照</button>
<view>预览</view>
<!-- <image mode="widthFix" src="{{src}}"></image> -->
<view>{{ok}}</view>
<view>{{text}}</view>
1 回复

麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

回到顶部