finclip单向视频录制插件

// pages/video/video.js
Page({

  data: {
    recordTime: 30000,
    top: 20,
    stepList: [
      {
        audioSrc: 'https://devtest-1252553964.cos.ap-guangzhou.myqcloud.com/1.mp3',
        showTime: 0,
        textList: [{
          text: '第一行文本',
          margin: '0 0 6rpx 0'
        }, {
          text: [{
            text: '第二行'
          }, {
            text: '高亮高亮',
            color: '#ee6f2d',
            fontWeight: 'bold',
            margin: '0 6rpx'
          }, {
            text: '文本文本文本文本文本'
          }]
        }, {
          text: '第三行文本文本文本文本文本',
          color: '#ee6f2d',
          margin:  '6rpx'
        }]
      },
      {
        audioSrc: 'https://devtest-1252553964.cos.ap-guangzhou.myqcloud.com/2.mp3',
        showTime: 8000,
        textList: [{
          text: '第二个文本',
          margin: '0 0 6rpx 0'
        }, {
          text: [{
            text: '文本'
          }, {
            text: '高亮',
            color: '#ee6f2d',
            fontWeight: 'bold',
            margin: '0 6rpx'
          }, {
            text: '文本文本文本文本文本'
          }, {
            text: '高亮',
            color: '#ee6f2d',
            fontWeight: 'bold',
            margin: '0 6rpx'
          }]
        }]
      },
      {
        audioSrc: 'https://devtest-1252553964.cos.ap-guangzhou.myqcloud.com/3.mp3',
        showTime: 18000,
        textList: [{
          text: '3第三个文本',
          margin: '0 0 6rpx 0'
        }, {
          text: [{
            text: '3第二行'
          }, {
            text: '3高亮3',
            color: '#ee6f2d',
            fontWeight: 'bold',
            margin: '0 6rpx'
          }, {
            text: '333文本文本文本文本文本文本333'
          }]
        }]
      }
    ],
    buttonStyle: {
      width: '16vw',
      height: '16vw',
      bottom: '80rpx'
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.showLoading()
  },

  onRecordReady() {
    wx.hideLoading()
  },

  onRecordStart() {
    wx.showToast({
      title: '录制开始',
      icon: 'none'
    })
  },

  onRecordEnd(res) {
    const { tempVideoPath } = res.detail
    wx.showToast({
      title: '录制结束,地址:' + tempVideoPath,
      icon: 'none'
    })
    setTimeout(() => {
      wx.navigateTo({
        url: '/pages/index/index?url=' + encodeURIComponent(tempVideoPath)
      })
    }, 3500)
  },

  onRecordError(res) {
    const { errMsg } = res.detail
    wx.showToast({
      title: errMsg,
      icon: 'none'
    })
  }
})
// pages/video/video.json
"usingComponents": {
    "video-recognition": "plugin://video/video-recognition"
}

// pages/video/video.fxml
<view style="width: 100vw;height: 100vh;">
  <video-recognition recordTime="{{recordTime}}"
                     top="{{top}}"
                     stepList="{{stepList}}"
                     buttonStyle="{{buttonStyle}}"
                     mask="/assets/img_mask_person@3x.png"
                     resolution="low"
                     bind:onRecordReady="onRecordReady"
                     bind:onRecordStart="onRecordStart"
                     bind:onRecordEnd="onRecordEnd"
                     bind:onRecordError="onRecordError">

  </video-recognition>
</view>

参数

属性类型是否必传默认值说明
resolutionStringmedium分辨率,可选值:low、medium、high 只在初始化时有效,不能动态变更
maskString-取景区域的遮罩资源路径,建议使用小程序内资源的相对路径,https 地址会有加载耗时, 遮罩会按 width 100% height 100% 的尺寸放在 camera 上,注意和组件尺寸相匹配
recordTimeNumber30000录制时间,单位为毫秒
topNumber20单位 rpx 文本提示距顶部的距离, 也可修改 video-recognition 组件内的 wxss,自定义文本的 position
stepListArray[Object]-见下方
buttonStyleObject-控制录制按钮的样式,可对按钮进行位置上的微调目前仅支持以下字段:width、height、left、top、bottom、right 只在初始化时有效,不能动态变更
onRecordReadyEventHandler-通过 onRecordReady 绑定 ready 前会进行一些异步资源的下载,资源准备好后触发可用于使用组件的 page 页面判断是否准备完毕,从而控制 loading 展示
onRecordStartEventHandler-通过 bind:onRecordStart 绑定录制开始时触发
onRecordEndEventHandler-通过 bind:onRecordEnd 绑定录制结束时触发回调方法参数 res:tempVideoPath 录制视频的本地文件地址
onRecordErrorEventHandler-通过 bind:onRecordError 绑定录制报错时触发回调方法参数 res:errMsg 发生错误时的报错信息

#setpList

每步的语和提示案配置,最大支持长度为 3 数据元素结构如下:

{
    "audioSrc": "https://xxxxx.mp3",
    "showTime": 0,
    "textList": []
}

audioSrc - 音频链接,建议使用 https 链接,组件 attached 会下载音频资源,若下载失败会执行 error 回调,报资源加载错误(注意:mp3 的域名需在管理后台添加到白名单内,否则会下载失败) showTime - 文本提示和音频的展示时间,毫秒数,0 表示初始展示,2000 表示录制开始 2s 时展示 textList - 文本提示,数组类型

textList 参数对象如下:

{
    "text": '请用普通话大声朗读'
}

text - 文本内容 可添加 width|height|padding|margin|color|fontSize|fontWeight|textAlign 等样式属性简单控制文本样式:

{
    "text": "文本",
    "color": "red",
    "fontWeight": "bold",
    "margin": "0 20rpx"
}

注意,一个 textList 子元素,展示时会以单行不换行展示,可按需拆分成多行多个子元素; 另外,如果单行内容内需要个别词语高亮展示,text 属性可以传入数组,属性与上述对象参数一致,如下:

{
    "text": [{
        "text": "文本"
    }, {
        "text": "高亮文本",
        "color": "red",
        "fontWeight": "bold",
        "margin": "0 20rpx"
    }, {
        "text": "文本"
    }]
}

只在初始化时有效,不能动态变更

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值