限时免费试用:欢迎注册 api.bigmodel.org ,快速体验大模型 API 接入服务。
当前位置:首页 >开发者 >网站框架 >小程序

小程序实例 | 视频播放加弹幕效果

分类:小程序时间:2018-12-23浏览:3559
js
Page({
  onReady(res) {
    this.videoContext = wx.createVideoContext('myVideo')
  },
  inputValue: '',
  data: {
    src: '',
    danmuList: [
      // {
      //   text: '第 1s 出现的弹幕',
      //   color: '#ff0000',
      //   time: 1
      // },
      // {
      //   text: '第 3s 出现的弹幕',
      //   color: '#ff00ff',
      //   time: 3
      // }
      ]
  },
  bindInputBlur(e) {
    this.inputValue = e.detail.value
  },
  bindButtonTap() {
    const that = this
    wx.chooseVideo({
      sourceType: ['album', 'camera'],
      maxDuration: 60,
      camera: ['front', 'back'],
      success(res) {
        that.setData({
          src: res.tempFilePath
        })
      }
    })
  },
  bindSendDanmu() {
    this.videoContext.sendDanmu({
      text: this.inputValue,
      color: '#ccc'
    })
  }
})
wxml

  
  
    
    
  
wxss
/* pages/video/index.wxss */
#myVideo{
  width: 100%
}
本站文章如未注明出处均为原创,转载请注明出处,如有侵权请邮件联系站长。
0/500
Share your thoughts respectfully.