VideoContext
通过 跟一个 video 组件绑定,操作对应的 组件。
播放视频
VideoContext.pause()
暂停视频
VideoContext.stop()
跳转到指定位置
VideoContext.sendDanmu(Object data)
发送弹幕
VideoContext.playbackRate(number rate)
设置倍速播放
VideoContext.exitFullScreen()
退出全屏
VideoContext.showStatusBar()
显示状态栏,仅在iOS全屏下有效
隐藏状态栏,仅在iOS全屏下有效
示例代码
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)
}
}
Page({
this.videoContext = wx.createVideoContext('myVideo')
},
inputValue: '',
this.inputValue = e.detail.value
},
bindSendDanmu () {
this.videoContext.sendDanmu({
text: this.inputValue,
color: getRandomColor()
})
})