onshow中使用cameraContext.startRecord 报错,闪退
发布于 6 年前 作者 min57 903 次浏览 来自 问答

先贴代码:

onShow: function () {
    var that = this;
    that.ctx = wx.createCameraContext()
    that.ctx.startRecord({
      success: (res) => {
        console.log('startRecord')
        setTimeout(function () {
          that.ctx.stopRecord({
            success: (res) => {
              that.setData({
                src: res.tempVideoPath
              })
            }
          })
        }, 5000)
      }
    })
  },

,这种写法在某一个版本库更新之后,突然如下错误报错:

然后在onshow中做了1秒延时,初步解决了这个问题,代码如下:

onShow: function () {
   var that = this;
   that.ctx = wx.createCameraContext()
   setTimeout(function(){
     that.ctx.startRecord({
       success: (res) => {
         console.log('startRecord')
         setTimeout(function () {
           that.ctx.stopRecord({
             success: (res) => {
               that.setData({
                 src: res.tempVideoPath
               })
             }
           })
         }, 5000)
       }
     })
   },1000)
 },

,但是经过多次真机测试,发现华为p9plus中,每次就会有一次微信闪退,小米机器未发现闪退现象,oppo中有闪退,但是几率特别小,可能几十次出现一次。请问这种情况该怎么解决?

还有,现在联系官方是在是太费劲了,能不能有客服保证开发人员能联系上呢。

8 回复

我也是诶

@ 小辣椒  官方可爱的小姐姐 ,你们找到问题了么 ,我要怎么做呢,跪求解决方案!

你好,请问

stopRecord拍摄视频成功后怎么获得视频的宽高值呢

wechatide://minicode/yS4pYhmZ6CZB

这是代码片段的链接

你好,请问只是出现报错还是直接闪退?报错是必现的吗

嗨  想找到官方给解答还真是不容易啊 ,哪位大神给点意见呗

另外,在startRecord前加上一秒延迟,即可解决上述片段报错问题,代码如下:

onShow: function () {
    var that = this;
    that.ctx = wx.createCameraContext()
    setTimeout(function () {
      that.ctx.startRecord({
        success: (res) => {
          console.log('startRecord')
          setTimeout(function () {
            that.ctx.stopRecord({
              success: (res) => {
                that.setData({
                  src: res.tempVideoPath
                })
              }
            })
          }, 5000)
        }
      })
    }, 2000)
     
  },

但是会导致微信闪退,手机型号:华为p9plus,android的版本为7.0,微信的版本为6.6.6,微信小程序的调试基础库为1.9.98。继续大神给出解决办法,毕竟小程序已经上线了很久了,突然出现这种问题,很难受。

回到顶部