建设并返回 video 上下文videoContext工具
videoContext通过 videoId 跟一个 video 组件绑定,,,,通过它可以操作一个 video 组件。。
videoContext工具的要领列表:
| 要领 | 参数 | 说明 | 最低版本 |
|---|---|---|---|
| play | 无 | 播放 | |
| pause | 无 | 暂停 | |
| seek | position | 跳转到指定位置,,,,单位 s | |
| sendDanmu | danmu | 发送弹幕,,,,danmu 包括两个属性 text, color。。 | |
| playbackRate | rate | 设置倍速播放,,,,支持的倍率有 0.5/0.8/1.0/1.25/1.5 | 1.4.0 |
| requestFullScreen | 无 | 进入全屏 | 1.4.0 |
| exitFullScreen | 无 | 退出全屏 | 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">发送弹幕</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()
})
}
})
更多微信小程序开发教程,,,,可以关注。。
KESION pp电子软件
KESION pp电子软件是海内领先的在线教育软件及私域社交电商软件服务提供商,,,,恒久专注于为企业提供在线教育软件及社交电商SaaS平台解决方案。。
公司焦点产品云开店SaaS社交电商服务平台、在线教育SaaS服务平台、教育企业数字化SaaS云平台、企微营销助手、私有化自力安排品牌网校和在线教育咨询等。。KESION 一直通过手艺立异,,,,提供产品和服务,,,,助力企业向数字化转型,,,,通过科技驱动商业刷新,,,,让商业变得更智慧!
wx.getBackgroundAudioPlayerState(OBJECT) 获取音乐播放状态。。 OBJECT参数说明: 参数 类型 必填 说明 success Function 否 接口挪用乐成
wx.createMapContext(mapId) 建设并返回 map 上下文 mapContext 工具。。在自界说组件下,,,,第二个参数传入组件实例this,,,,以操作组件内 map/ 组件 mapCon