VideoContext

    通过 跟一个 video 组件绑定,操作对应的 组件。

    播放视频

    VideoContext.pause()

    暂停视频

    VideoContext.stop()

    跳转到指定位置

    VideoContext.sendDanmu(Object data)

    发送弹幕

    VideoContext.playbackRate(number rate)

    设置倍速播放

    VideoContext.exitFullScreen()

    退出全屏

    VideoContext.showStatusBar()

    显示状态栏,仅在iOS全屏下有效

    隐藏状态栏,仅在iOS全屏下有效

    示例代码

    1. function getRandomColor () {
    2. let rgb = []
    3. for (let i = 0 ; i < 3; ++i) {
    4. let color = Math.floor(Math.random() * 256).toString(16)
    5. color = color.length == 1 ? '0' + color : color
    6. rgb.push(color)
    7. }
    8. }
    9. Page({
    10. this.videoContext = wx.createVideoContext('myVideo')
    11. },
    12. inputValue: '',
    13. this.inputValue = e.detail.value
    14. },
    15. bindSendDanmu () {
    16. this.videoContext.sendDanmu({
    17. text: this.inputValue,
    18. color: getRandomColor()
    19. })
    20. })