Component({
  properties: {
    title: {
      type: String,
      value: '',
    },
    intro: {
      type: String,
      value: '',
    },
    hint: {
      type: String,
      value: '',
    },
    code: {
      type: String,
      value: '',
    },
    json: {
      type: String,
      value: '',
    },
    js: {
      type: String,
      value: '',
    },
    showBackBtn: {
      type: Boolean,
      value: false,
    },
    recordState: 0,
  },
  data: {
  },
  lifetimes: {
    attached() {
      wx.xrTitle = this.data.title;
    }
  },
  captureQuality: {
    type: Number,
    value: 0.8,
  },
  captureType: {
    type: String,
    value: 'jpg',
  },
  recordFPS: {
    type: Number,
    value: 30,
  },
  methods: {
    recordStart() {
      console.log('recordStart') 
      wx.updateShareMenu({
        withShareTicket: true,
        success () { }
      })
      this.scene.share.recordStart({
        fps: 15,
        videoBitsPerSecond: 10000,
      });
    },
    recordEnd() {
      console.log('recordEnd')
      const tempFilePath =  this.scene.share.recordFinishToAlbum({
        fps: 15,
        videoBitsPerSecond: 10000,
      });
      wx.shareVideoMessage({
        videoPath: tempFilePath,
      });
    },
    onClickBack() {
      wx.navigateBack()
    },
    /**
     * 获取系统信息 设置相机的大小适应屏幕
     */
    setCameraSize() {
      //获取设备信息
      const res =  wx.getSystemSetting();
      //获取屏幕的可使用宽高，设置给相机
      this.setData({
        cameraHeight: res.windowHeight,
        cameraWidth: res.windowWidth
      })
      console.log(res)
    },
  
  
    /**
     * 开始录像的方法
     */
    startShootVideo() {
  
      console.log("========= 调用开始录像 ===========")
      this.ctx.startRecord({
        success: (res) => {
          wx.showLoading({
            title: '正在录像',
          })
        },
        fail() {
          console.log("========= 调用开始录像失败 ===========")
        }
      })
    },
  
    /**
     * 结束录像
     */
    stopShootVideo() {
  
      console.log("========= 调用结束录像 ===========")
      this.ctx.stopRecord({
        success: (res) => {
          wx.hideLoading();
          this.setData({
            videoSrc: res.tempVideoPath,
          })
        },
        fail() {
          wx.hideLoading();
          console.log("========= 调用结束录像失败 ===========")
        }
      })
    }
  },
  options: {
    multipleSlots: true
  }
})