最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序 vidao實現(xiàn)視頻播放和彈幕的功能

 更新時間:2016年11月02日 16:03:46   投稿:lqh  
這篇文章主要介紹了微信小程序 vidao實現(xiàn)視頻播放和彈幕的功能的相關資料,這里提供實現(xiàn)代碼及實現(xiàn)效果圖,需要的朋友可以參考下

 微信小程序 vidao視頻播放及彈幕的功能的實現(xiàn)。

vidao

我現(xiàn)在看到的官方文檔是不帶danmu(彈幕)屬性的,之前是有的,不過現(xiàn)在這個屬性還可以生效。控制視頻的狀態(tài)可以根據(jù)video標簽的唯一id得到一個對象實例。video組件并不具備action屬性,不能通過action來控制。

.wxml

<view class="section tc">
 <video src="{{src}}"  controls ></video>
 <view class="btn-area">
  <button bindtap="bindButtonTap">獲取視頻</button>
 </view>
</view>

<!-- 
 danmu-list:彈幕列表
 enable-danmu:是否顯示彈幕
 danmu-btn:彈幕按鈕
 controls:是否顯示視頻控件,并沒有什么用
 -->
<view class="section tc">
 <video id="myVideo" src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400" binderror="videoErrorCallback" danmu-list="{{danmuList}}" enable-danmu danmu-btn controls></video>
 <view class="btn-area">
  <button bindtap="bindButtonTap">獲取視頻</button>
  <input bindblur="bindInputBlur"/>
  <button bindtap="bindSendDanmu">發(fā)送彈幕</button>
 </view>
</view>

<!-- 現(xiàn)在的video就下面三個屬性 -->
<video src="" binderror="" hidden></video>

.js

function getRandomColor () {
 let rgb = []
 for (let i = 0 ; i < 3; ++i){
  let color = Math.floor(Math.random() * 256).toString(16)
  color = color.length == 1 ? '0' + color : color
  rgb.push(color)
 }
 return '#' + rgb.join('')
}

Page({
 onReady: function (res) {
  this.videoContext = wx.createVideoContext('myVideo')
 },
 inputValue: '',
  data: {
    src: '',
  danmuList: [
   {
    text: '第 1s 出現(xiàn)的彈幕',
    color: '#ff0000',
    time: 1
   },
   {
    text: '第 3s 出現(xiàn)的彈幕',
    color: '#ff00ff',
    time: 3
   }
  ]
  },
 bindInputBlur: function(e) {
  this.inputValue = e.detail.value
 },
  bindButtonTap: function() { //視頻下載
    var that = this
    wx.chooseVideo({
      sourceType: ['album', 'camera'],
      maxDuration: 60,
      camera: ['front','back'],
      success: function(res) {
        that.setData({
          src: res.tempFilePath
        })
      }
    })
  },
 bindSendDanmu: function () {
  this.videoContext.sendDanmu({
   text: this.inputValue,
   color: getRandomColor()
  })
 },
  videoErrorCallback: function(e) {
   console.log('視頻錯誤信息:');
   console.log(e.detail.errMsg);
  }
})

效果

 

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關文章

最新評論

德安县| 都安| 澄城县| 东辽县| 兰州市| 青海省| 全州县| 元氏县| 普兰店市| 普陀区| 大化| 绥阳县| 高州市| 哈密市| 海盐县| 大埔县| 乌拉特后旗| 鲁山县| 平原县| 潍坊市| 海阳市| 石嘴山市| 迭部县| 德钦县| 台江县| 防城港市| 巩留县| 于都县| 台安县| 江城| 钟山县| 清远市| 深水埗区| 蒙山县| 青冈县| 房产| 潜江市| 漠河县| 图片| 武城县| 华蓥市|