溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

微信小程序videoContext怎么用

發(fā)布時(shí)間:2022-03-10 14:39:54 來(lái)源:億速云 閱讀:577 作者:iii 欄目:開(kāi)發(fā)技術(shù)

這篇文章主要介紹了微信小程序videoContext怎么用的相關(guān)知識(shí),內(nèi)容詳細(xì)易懂,操作簡(jiǎn)單快捷,具有一定借鑒價(jià)值,相信大家閱讀完這篇微信小程序videoContext怎么用文章都會(huì)有所收獲,下面我們一起來(lái)看看吧。

wx.createVideoContext(videoId)


創(chuàng)建并返回 video 上下文videoContext對(duì)象

videoContext

videoContext通過(guò) videoId 跟一個(gè) video 組件綁定,通過(guò)它可以操作一個(gè) video 組件。

videoContext對(duì)象的方法列表:

方法 參數(shù) 說(shuō)明 最低版本
play 無(wú) 播放  
pause 無(wú) 暫停  
seek position 跳轉(zhuǎn)到指定位置,單位 s  
sendDanmu danmu 發(fā)送彈幕,danmu 包含兩個(gè)屬性 text, color。  
playbackRate rate 設(shè)置倍速播放,支持的倍率有 0.5/0.8/1.0/1.25/1.5 1.4.0
requestFullScreen 無(wú) 進(jìn)入全屏 1.4.0
exitFullScreen 無(wú) 退出全屏 1.4.0

示例代碼:

<view class="section tc">  <video id="myVideo" src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400"   enable-danmu danmu-btn controls></video>
  <view class="btn-area"><input bindblur="bindInputBlur"/><button bindtap="bindSendDanmu">發(fā)送彈幕</button>
  </view></view>
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: '',
  bindInputBlur: function(e) {this.inputValue = e.detail.value
  },
  bindSendDanmu: function () {this.videoContext.sendDanmu({
      text: this.inputValue,
      color: getRandomColor()
    })
  }
})

關(guān)于“微信小程序videoContext怎么用”這篇文章的內(nèi)容就介紹到這里,感謝各位的閱讀!相信大家對(duì)“微信小程序videoContext怎么用”知識(shí)都有一定的了解,大家如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI