Skip to content

Commit 158c72b

Browse files
committed
update: 更新 <video>
1 parent ba3d85d commit 158c72b

1 file changed

Lines changed: 100 additions & 0 deletions

File tree

‎pages/component/video/video.nvue‎

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<template>
2+
<div>
3+
<video id='video1' class="video" :src="src" autoplay="false" duration="" controls="true" :danmu-list="list"
4+
danmu-btn="true" enable-danmu="true" :loop="true" muted="true" initial-time="" direction="-90"
5+
show-mute-btn="true" @play="onstart" @pause="onpause" @ended="onfinish" @error="onfail" @waiting="waiting"
6+
@timeupdate="timeupdate" @fullscreenchange="fullscreenchange"></video>
7+
<button class="btn" @click="play">播放</button>
8+
<button class="btn" @click="pause">暂停</button>
9+
<button class="btn" @click="seek">跳转到指定位置</button>
10+
<button class="btn" @click="stop">停止</button>
11+
<button class="btn" @click="fullScreen">全屏</button>
12+
<button class="btn" @click="exitFullScreen">退出全屏</button>
13+
<button class="btn" @click="playbackRate">设置倍速</button>
14+
<button class="btn" @click="sendDanmu">发送弹幕</button>
15+
</div>
16+
</template>
17+
18+
<script>
19+
export default {
20+
data: {
21+
src: "https://img.cdn.aliyun.dcloud.net.cn/guide/uniapp/%E7%AC%AC1%E8%AE%B2%EF%BC%88uni-app%E4%BA%A7%E5%93%81%E4%BB%8B%E7%BB%8D%EF%BC%89-%20DCloud%E5%AE%98%E6%96%B9%E8%A7%86%E9%A2%91%E6%95%99%E7%A8%8B@20181126.mp4",
22+
fil: true,
23+
list: [{
24+
text: '要显示的sdfa本',
25+
color: '#FF0000',
26+
time: 9
27+
}]
28+
},
29+
onReady() {
30+
this.context = uni.createVideoContext("video1", this);
31+
},
32+
methods: {
33+
onstart(e) {
34+
console.log("onstart:" + JSON.stringify(e));
35+
},
36+
onpause(e) {
37+
console.log("onpause:" + JSON.stringify(e));
38+
},
39+
onfinish(e) {
40+
console.log("onfinish:" + JSON.stringify(e));
41+
},
42+
onfail(e) {
43+
console.log("onfail:" + JSON.stringify(e));
44+
},
45+
fullscreenchange(e) {
46+
console.log("fullscreenchange:" + JSON.stringify(e));
47+
},
48+
waiting(e) {
49+
console.log("waiting:" + JSON.stringify(e));
50+
},
51+
timeupdate(e) {
52+
console.log("timeupdate:" + JSON.stringify(e));
53+
},
54+
55+
play() {
56+
this.context.play();
57+
},
58+
pause() {
59+
this.context.pause();
60+
},
61+
seek() {
62+
this.context.seek(20);
63+
},
64+
stop() {
65+
this.context.stop();
66+
},
67+
fullScreen() {
68+
this.context.requestFullScreen({
69+
direction: 90
70+
});
71+
},
72+
exitFullScreen() {
73+
this.context.exitFullScreen();
74+
},
75+
sendDanmu() {
76+
this.context.sendDanmu({
77+
text: '要显示的弹幕文本',
78+
color: '#FF0000'
79+
});
80+
},
81+
playbackRate() {
82+
this.context.playbackRate(2);
83+
}
84+
}
85+
}
86+
</script>
87+
88+
<style>
89+
.video {
90+
width: 750rpx;
91+
height: 400rpx;
92+
background-color: #808080;
93+
}
94+
95+
.btn {
96+
margin-top: 5px;
97+
margin-bottom: 5px;
98+
;
99+
}
100+
</style>

0 commit comments

Comments
 (0)