tt.createVideoContext
基础库 1.18.0 开始支持本方法,低版本需做兼容处理。 这是一个同步方法。
根据 <video /> 组件 id
创建可以控制组件的上下文 VideoContext 对象。
语法
tt.createVideoContext(id[, component])
参数说明
参数名 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
id | string | 是 | ttml 中组件的 id | |
component | object | 否 | 在自定义组件下,当前组件实例的 this,以操作组件内 <video /> 组件 |
返回值
返回 VideoContext 对象
扫码体验
请使用字节宿主APP扫码
代码示例
<video
src="http://sf1-ttcdn-tos.pstatp.com/obj/ttfe/test/test-upload.mp4"
id="myVideo"
style="width: 240px; height: 180px;"
/>
Page({
videoContext: undefined,
onReady() {
this.videoContext = tt.createVideoContext("myVideo");
},
});
Bug & Tip
无
点击纠错
评价此篇文档