视频 API
createVideoContext
ty.createVideoContext(string id)
创建 video 上下文 VideoContext 对象。
参数
string id
video 组件的 id
返回值
VideoContext
VideoContext 实例,可通过 ty.createVideoContext 获取。
VideoContext 通过 id 跟一个 video 组件绑定,操作对应的 video 组件。
方法
VideoContext.play
VideoContext.play()
播放视频
VideoContext.pause
VideoContext.pause()
暂停视频
VideoContext.stop
VideoContext.stop()
停止视频
VideoContext.playbackRate
VideoContext.playbackRate(number rate)
设置倍速播放
VideoContext.seek
VideoContext.seek(number position)
跳转到指定位置
参数
number position
跳转到的位置,单位 s
VideoContext.sendDanmu
VideoContext.sendDanmu(Object data)
发送弹幕
参数
Object data
弹幕内容
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
text | string | 是 | 弹幕文字 | |
color | string | 否 | 弹幕颜色 |
👉 立即开发。
原生视频 API
createNativeVideoContext
ty.createNativeVideoContext(string id)
创建