js-components-media-video.md 10.6 KB
Newer Older
Z
zengyawen 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# video<a name="ZH-CN_TOPIC_0000001173164749"></a>

视频播放组件。

>![](../../public_sys-resources/icon-note.gif) **说明:** 
>-   需要在config.json配置
>    ```
>    "configChanges": ["orientation"]
>    ```

## 权限列表<a name="section11257113618419"></a>

## 子组件<a name="sc18e8342b29747dbbd70887cc3c0a22d"></a>

不支持。

## 属性<a name="s50d82bce96774b86846ab2739d7ce18d"></a>

除支持[通用属性](js-components-common-attributes.md)外,还支持如下样式:

Z
zengyawen 已提交
21
<table><thead align="left"><tr><th class="cellrowborder" valign="top" width="15.479999999999999%" id="mcps1.1.6.1.1"><p>名称</p>
Z
zengyawen 已提交
22
</th>
Z
zengyawen 已提交
23
<th class="cellrowborder" valign="top" width="13.04%" id="mcps1.1.6.1.2"><p>类型</p>
Z
zengyawen 已提交
24
</th>
Z
zengyawen 已提交
25
<th class="cellrowborder" valign="top" width="11.41%" id="mcps1.1.6.1.3"><p>默认值</p>
Z
zengyawen 已提交
26
</th>
Z
zengyawen 已提交
27
<th class="cellrowborder" valign="top" width="8.73%" id="mcps1.1.6.1.4"><p>必填</p>
Z
zengyawen 已提交
28
</th>
Z
zengyawen 已提交
29
<th class="cellrowborder" valign="top" width="51.339999999999996%" id="mcps1.1.6.1.5"><p>描述</p>
Z
zengyawen 已提交
30 31 32
</th>
</tr>
</thead>
Z
zengyawen 已提交
33
<tbody><tr><td class="cellrowborder" valign="top" width="15.479999999999999%" headers="mcps1.1.6.1.1 "><p>muted</p>
Z
zengyawen 已提交
34
</td>
Z
zengyawen 已提交
35
<td class="cellrowborder" valign="top" width="13.04%" headers="mcps1.1.6.1.2 "><p>boolean</p>
Z
zengyawen 已提交
36
</td>
Z
zengyawen 已提交
37
<td class="cellrowborder" valign="top" width="11.41%" headers="mcps1.1.6.1.3 "><p>false</p>
Z
zengyawen 已提交
38
</td>
Z
zengyawen 已提交
39
<td class="cellrowborder" valign="top" width="8.73%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
40
</td>
Z
zengyawen 已提交
41
<td class="cellrowborder" valign="top" width="51.339999999999996%" headers="mcps1.1.6.1.5 "><p>视频是否静音播放。</p>
Z
zengyawen 已提交
42 43
</td>
</tr>
Z
zengyawen 已提交
44
<tr><td class="cellrowborder" valign="top" width="15.479999999999999%" headers="mcps1.1.6.1.1 "><p>src</p>
Z
zengyawen 已提交
45
</td>
Z
zengyawen 已提交
46
<td class="cellrowborder" valign="top" width="13.04%" headers="mcps1.1.6.1.2 "><p>string</p>
Z
zengyawen 已提交
47
</td>
Z
zengyawen 已提交
48
<td class="cellrowborder" valign="top" width="11.41%" headers="mcps1.1.6.1.3 "><p>-</p>
Z
zengyawen 已提交
49
</td>
Z
zengyawen 已提交
50
<td class="cellrowborder" valign="top" width="8.73%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
51
</td>
Z
zengyawen 已提交
52
<td class="cellrowborder" valign="top" width="51.339999999999996%" headers="mcps1.1.6.1.5 "><p>播放视频内容的路径。</p>
Z
zengyawen 已提交
53 54
</td>
</tr>
Z
zengyawen 已提交
55
<tr><td class="cellrowborder" valign="top" width="15.479999999999999%" headers="mcps1.1.6.1.1 "><p>autoplay</p>
Z
zengyawen 已提交
56
</td>
Z
zengyawen 已提交
57
<td class="cellrowborder" valign="top" width="13.04%" headers="mcps1.1.6.1.2 "><p>boolean</p>
Z
zengyawen 已提交
58
</td>
Z
zengyawen 已提交
59
<td class="cellrowborder" valign="top" width="11.41%" headers="mcps1.1.6.1.3 "><p>false</p>
Z
zengyawen 已提交
60
</td>
Z
zengyawen 已提交
61
<td class="cellrowborder" valign="top" width="8.73%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
62
</td>
Z
zengyawen 已提交
63
<td class="cellrowborder" valign="top" width="51.339999999999996%" headers="mcps1.1.6.1.5 "><p>视频是否自动播放。</p>
Z
zengyawen 已提交
64 65
</td>
</tr>
Z
zengyawen 已提交
66
<tr><td class="cellrowborder" valign="top" width="15.479999999999999%" headers="mcps1.1.6.1.1 "><p>controls</p>
Z
zengyawen 已提交
67
</td>
Z
zengyawen 已提交
68
<td class="cellrowborder" valign="top" width="13.04%" headers="mcps1.1.6.1.2 "><p>boolean</p>
Z
zengyawen 已提交
69
</td>
Z
zengyawen 已提交
70
<td class="cellrowborder" valign="top" width="11.41%" headers="mcps1.1.6.1.3 "><p>true</p>
Z
zengyawen 已提交
71
</td>
Z
zengyawen 已提交
72
<td class="cellrowborder" valign="top" width="8.73%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
73
</td>
Z
zengyawen 已提交
74
<td class="cellrowborder" valign="top" width="51.339999999999996%" headers="mcps1.1.6.1.5 "><p>控制视频播放的控制栏是否显示,如果设置为false,则不显示控制栏。默认为true,由系统决定显示或隐藏控制栏。</p>
Z
zengyawen 已提交
75 76 77 78 79 80 81 82 83
</td>
</tr>
</tbody>
</table>

## 样式<a name="sfbde25405aca4513a9c938f2f339b770"></a>

除支持[通用样式](js-components-common-styles.md)外,还支持如下样式:

Z
zengyawen 已提交
84
<table><thead align="left"><tr><th class="cellrowborder" valign="top" width="23.11768823117688%" id="mcps1.1.6.1.1"><p>名称</p>
Z
zengyawen 已提交
85
</th>
Z
zengyawen 已提交
86
<th class="cellrowborder" valign="top" width="20.477952204779523%" id="mcps1.1.6.1.2"><p>类型</p>
Z
zengyawen 已提交
87
</th>
Z
zengyawen 已提交
88
<th class="cellrowborder" valign="top" width="8.869113088691131%" id="mcps1.1.6.1.3"><p>默认值</p>
Z
zengyawen 已提交
89
</th>
Z
zengyawen 已提交
90
<th class="cellrowborder" valign="top" width="7.519248075192481%" id="mcps1.1.6.1.4"><p>必填</p>
Z
zengyawen 已提交
91
</th>
Z
zengyawen 已提交
92
<th class="cellrowborder" valign="top" width="40.01599840015999%" id="mcps1.1.6.1.5"><p>描述</p>
Z
zengyawen 已提交
93 94 95
</th>
</tr>
</thead>
Z
zengyawen 已提交
96
<tbody><tr><td class="cellrowborder" valign="top" width="23.11768823117688%" headers="mcps1.1.6.1.1 "><p>object-fit</p>
Z
zengyawen 已提交
97
</td>
Z
zengyawen 已提交
98
<td class="cellrowborder" valign="top" width="20.477952204779523%" headers="mcps1.1.6.1.2 "><p>string</p>
Z
zengyawen 已提交
99
</td>
Z
zengyawen 已提交
100
<td class="cellrowborder" valign="top" width="8.869113088691131%" headers="mcps1.1.6.1.3 "><p>contain</p>
Z
zengyawen 已提交
101
</td>
Z
zengyawen 已提交
102
<td class="cellrowborder" valign="top" width="7.519248075192481%" headers="mcps1.1.6.1.4 "><p></p>
Z
zengyawen 已提交
103
</td>
Z
zengyawen 已提交
104
<td class="cellrowborder" valign="top" width="40.01599840015999%" headers="mcps1.1.6.1.5 "><p>视频源的缩放类型,如果poster设置了值,那么此配置还会影响视频海报的缩放类型,可选值参考<a href="#t8eca568266d54af484fec0f84185e923">表1</a></p>
Z
zengyawen 已提交
105 106 107 108 109 110 111 112
</td>
</tr>
</tbody>
</table>

**表 1**  object-fit 类型说明

<a name="t8eca568266d54af484fec0f84185e923"></a>
Z
zengyawen 已提交
113
<table><thead align="left"><tr><th class="cellrowborder" valign="top" width="15.02%" id="mcps1.2.3.1.1"><p>类型</p>
Z
zengyawen 已提交
114
</th>
Z
zengyawen 已提交
115
<th class="cellrowborder" valign="top" width="84.98%" id="mcps1.2.3.1.2"><p>描述</p>
Z
zengyawen 已提交
116 117 118
</th>
</tr>
</thead>
Z
zengyawen 已提交
119
<tbody><tr><td class="cellrowborder" valign="top" width="15.02%" headers="mcps1.2.3.1.1 "><p>fill</p>
Z
zengyawen 已提交
120
</td>
Z
zengyawen 已提交
121
<td class="cellrowborder" valign="top" width="84.98%" headers="mcps1.2.3.1.2 "><p>不保持宽高比进行放大缩小,使得图片填充满显示边界。</p>
Z
zengyawen 已提交
122 123 124 125 126 127 128 129 130
</td>
</tr>
</tbody>
</table>

## 事件<a name="section4181420161817"></a>

除支持[通用事件](js-components-common-events.md)外,还支持如下事件:

Z
zengyawen 已提交
131
<table><thead align="left"><tr><th class="cellrowborder" valign="top" width="24.852485248524854%" id="mcps1.1.4.1.1"><p>名称</p>
Z
zengyawen 已提交
132
</th>
Z
zengyawen 已提交
133
<th class="cellrowborder" valign="top" width="29.552955295529554%" id="mcps1.1.4.1.2"><p>参数</p>
Z
zengyawen 已提交
134
</th>
Z
zengyawen 已提交
135
<th class="cellrowborder" valign="top" width="45.5945594559456%" id="mcps1.1.4.1.3"><p>描述</p>
Z
zengyawen 已提交
136 137 138
</th>
</tr>
</thead>
Z
zengyawen 已提交
139
<tbody><tr><td class="cellrowborder" valign="top" width="24.852485248524854%" headers="mcps1.1.4.1.1 "><p>prepared</p>
Z
zengyawen 已提交
140
</td>
Z
zengyawen 已提交
141
<td class="cellrowborder" valign="top" width="29.552955295529554%" headers="mcps1.1.4.1.2 "><p>{ duration: value }<sup>5+</sup></p>
Z
zengyawen 已提交
142
</td>
Z
zengyawen 已提交
143
<td class="cellrowborder" valign="top" width="45.5945594559456%" headers="mcps1.1.4.1.3 "><p>视频准备完成时触发该事件,通过duration可以获取视频时长,单位为s。</p>
Z
zengyawen 已提交
144 145
</td>
</tr>
Z
zengyawen 已提交
146
<tr><td class="cellrowborder" valign="top" width="24.852485248524854%" headers="mcps1.1.4.1.1 "><p>start</p>
Z
zengyawen 已提交
147
</td>
Z
zengyawen 已提交
148
<td class="cellrowborder" valign="top" width="29.552955295529554%" headers="mcps1.1.4.1.2 "><p>-</p>
Z
zengyawen 已提交
149
</td>
Z
zengyawen 已提交
150
<td class="cellrowborder" valign="top" width="45.5945594559456%" headers="mcps1.1.4.1.3 "><p>播放时触发该事件。</p>
Z
zengyawen 已提交
151 152
</td>
</tr>
Z
zengyawen 已提交
153
<tr><td class="cellrowborder" valign="top" width="24.852485248524854%" headers="mcps1.1.4.1.1 "><p>pause</p>
Z
zengyawen 已提交
154
</td>
Z
zengyawen 已提交
155
<td class="cellrowborder" valign="top" width="29.552955295529554%" headers="mcps1.1.4.1.2 "><p>-</p>
Z
zengyawen 已提交
156
</td>
Z
zengyawen 已提交
157
<td class="cellrowborder" valign="top" width="45.5945594559456%" headers="mcps1.1.4.1.3 "><p>暂停时触发该事件。</p>
Z
zengyawen 已提交
158 159
</td>
</tr>
Z
zengyawen 已提交
160
<tr><td class="cellrowborder" valign="top" width="24.852485248524854%" headers="mcps1.1.4.1.1 "><p>finish</p>
Z
zengyawen 已提交
161
</td>
Z
zengyawen 已提交
162
<td class="cellrowborder" valign="top" width="29.552955295529554%" headers="mcps1.1.4.1.2 "><p>-</p>
Z
zengyawen 已提交
163
</td>
Z
zengyawen 已提交
164
<td class="cellrowborder" valign="top" width="45.5945594559456%" headers="mcps1.1.4.1.3 "><p>播放结束时触发该事件。</p>
Z
zengyawen 已提交
165 166
</td>
</tr>
Z
zengyawen 已提交
167
<tr><td class="cellrowborder" valign="top" width="24.852485248524854%" headers="mcps1.1.4.1.1 "><p>error</p>
Z
zengyawen 已提交
168
</td>
Z
zengyawen 已提交
169
<td class="cellrowborder" valign="top" width="29.552955295529554%" headers="mcps1.1.4.1.2 "><p>-</p>
Z
zengyawen 已提交
170
</td>
Z
zengyawen 已提交
171
<td class="cellrowborder" valign="top" width="45.5945594559456%" headers="mcps1.1.4.1.3 "><p>播放失败时触发该事件。</p>
Z
zengyawen 已提交
172 173
</td>
</tr>
Z
zengyawen 已提交
174
<tr><td class="cellrowborder" valign="top" width="24.852485248524854%" headers="mcps1.1.4.1.1 "><p>seeking</p>
Z
zengyawen 已提交
175
</td>
Z
zengyawen 已提交
176
<td class="cellrowborder" valign="top" width="29.552955295529554%" headers="mcps1.1.4.1.2 "><p>{ currenttime: value }</p>
Z
zengyawen 已提交
177
</td>
Z
zengyawen 已提交
178
<td class="cellrowborder" valign="top" width="45.5945594559456%" headers="mcps1.1.4.1.3 "><p>操作进度条过程时上报时间信息,单位为s。</p>
Z
zengyawen 已提交
179 180
</td>
</tr>
Z
zengyawen 已提交
181
<tr><td class="cellrowborder" valign="top" width="24.852485248524854%" headers="mcps1.1.4.1.1 "><p>seeked</p>
Z
zengyawen 已提交
182
</td>
Z
zengyawen 已提交
183
<td class="cellrowborder" valign="top" width="29.552955295529554%" headers="mcps1.1.4.1.2 "><p>{ currenttime: value }</p>
Z
zengyawen 已提交
184
</td>
Z
zengyawen 已提交
185
<td class="cellrowborder" valign="top" width="45.5945594559456%" headers="mcps1.1.4.1.3 "><p>操作进度条完成后,上报播放时间信息,单位为s。</p>
Z
zengyawen 已提交
186 187
</td>
</tr>
Z
zengyawen 已提交
188
<tr><td class="cellrowborder" valign="top" width="24.852485248524854%" headers="mcps1.1.4.1.1 "><p>timeupdate</p>
Z
zengyawen 已提交
189
</td>
Z
zengyawen 已提交
190
<td class="cellrowborder" valign="top" width="29.552955295529554%" headers="mcps1.1.4.1.2 "><p>{ currenttime: value }</p>
Z
zengyawen 已提交
191
</td>
Z
zengyawen 已提交
192
<td class="cellrowborder" valign="top" width="45.5945594559456%" headers="mcps1.1.4.1.3 "><p>播放进度变化时触发该事件,单位为s,更新时间间隔为250ms。</p>
Z
zengyawen 已提交
193 194 195 196 197 198 199 200 201
</td>
</tr>
</tbody>
</table>

## 方法<a name="s557cc2f457ff42a193807500adae2f91"></a>

除支持[通用方法](js-components-common-methods.md)外,还支持如下方法:

Z
zengyawen 已提交
202
<table><thead align="left"><tr><th class="cellrowborder" valign="top" width="28.000000000000004%" id="mcps1.1.4.1.1"><p>名称</p>
Z
zengyawen 已提交
203
</th>
Z
zengyawen 已提交
204
<th class="cellrowborder" valign="top" width="29.82%" id="mcps1.1.4.1.2"><p>参数</p>
Z
zengyawen 已提交
205
</th>
Z
zengyawen 已提交
206
<th class="cellrowborder" valign="top" width="42.18%" id="mcps1.1.4.1.3"><p>描述</p>
Z
zengyawen 已提交
207 208 209
</th>
</tr>
</thead>
Z
zengyawen 已提交
210
<tbody><tr><td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.1.4.1.1 "><p>start</p>
Z
zengyawen 已提交
211
</td>
Z
zengyawen 已提交
212
<td class="cellrowborder" valign="top" width="29.82%" headers="mcps1.1.4.1.2 "><p>-</p>
Z
zengyawen 已提交
213
</td>
Z
zengyawen 已提交
214
<td class="cellrowborder" valign="top" width="42.18%" headers="mcps1.1.4.1.3 "><p>请求播放视频。</p>
Z
zengyawen 已提交
215 216
</td>
</tr>
Z
zengyawen 已提交
217
<tr><td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.1.4.1.1 "><p>pause</p>
Z
zengyawen 已提交
218
</td>
Z
zengyawen 已提交
219
<td class="cellrowborder" valign="top" width="29.82%" headers="mcps1.1.4.1.2 "><p>-</p>
Z
zengyawen 已提交
220
</td>
Z
zengyawen 已提交
221
<td class="cellrowborder" valign="top" width="42.18%" headers="mcps1.1.4.1.3 "><p>请求暂停播放视频。</p>
Z
zengyawen 已提交
222 223
</td>
</tr>
Z
zengyawen 已提交
224
<tr><td class="cellrowborder" valign="top" width="28.000000000000004%" headers="mcps1.1.4.1.1 "><p>setCurrentTime</p>
Z
zengyawen 已提交
225
</td>
Z
zengyawen 已提交
226
<td class="cellrowborder" valign="top" width="29.82%" headers="mcps1.1.4.1.2 "><p>{ currenttime: value }</p>
Z
zengyawen 已提交
227
</td>
Z
zengyawen 已提交
228
<td class="cellrowborder" valign="top" width="42.18%" headers="mcps1.1.4.1.3 "><p>指定视频播放的进度位置,单位为s。</p>
Z
zengyawen 已提交
229 230 231 232 233
</td>
</tr>
</tbody>
</table>

Z
zengyawen 已提交
234 235 236
>![](../../public_sys-resources/icon-note.gif) **说明:** 
>在attached组件生命周期回调后,可以调用上述组件方法。