|
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% [email protected]", |
22 |
| - fil: true, |
23 |
| - list: [{ |
24 |
| - text: '要显示的文本', |
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 |
| - /* #ifdef H5 */ |
92 |
| - width: 100%; |
93 |
| - /* #endif */ |
94 |
| - height: 400rpx; |
95 |
| - background-color: #808080; |
96 |
| - } |
97 |
| - |
98 |
| - .btn { |
99 |
| - margin-top: 5px; |
100 |
| - margin-bottom: 5px; |
101 |
| - } |
| 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 | + return { |
| 22 | + 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% [email protected]", |
| 23 | + fil: true, |
| 24 | + list: [{ |
| 25 | + text: '要显示的文本', |
| 26 | + color: '#FF0000', |
| 27 | + time: 9 |
| 28 | + }] |
| 29 | + } |
| 30 | + }, |
| 31 | + onReady() { |
| 32 | + this.context = uni.createVideoContext("video1", this); |
| 33 | + }, |
| 34 | + methods: { |
| 35 | + onstart(e) { |
| 36 | + console.log("onstart:" + JSON.stringify(e)); |
| 37 | + }, |
| 38 | + onpause(e) { |
| 39 | + console.log("onpause:" + JSON.stringify(e)); |
| 40 | + }, |
| 41 | + onfinish(e) { |
| 42 | + console.log("onfinish:" + JSON.stringify(e)); |
| 43 | + }, |
| 44 | + onfail(e) { |
| 45 | + console.log("onfail:" + JSON.stringify(e)); |
| 46 | + }, |
| 47 | + fullscreenchange(e) { |
| 48 | + console.log("fullscreenchange:" + JSON.stringify(e)); |
| 49 | + }, |
| 50 | + waiting(e) { |
| 51 | + console.log("waiting:" + JSON.stringify(e)); |
| 52 | + }, |
| 53 | + timeupdate(e) { |
| 54 | + console.log("timeupdate:" + JSON.stringify(e)); |
| 55 | + }, |
| 56 | + |
| 57 | + play() { |
| 58 | + this.context.play(); |
| 59 | + }, |
| 60 | + pause() { |
| 61 | + this.context.pause(); |
| 62 | + }, |
| 63 | + seek() { |
| 64 | + this.context.seek(20); |
| 65 | + }, |
| 66 | + stop() { |
| 67 | + this.context.stop(); |
| 68 | + }, |
| 69 | + fullScreen() { |
| 70 | + this.context.requestFullScreen({ |
| 71 | + direction: 90 |
| 72 | + }); |
| 73 | + }, |
| 74 | + exitFullScreen() { |
| 75 | + this.context.exitFullScreen(); |
| 76 | + }, |
| 77 | + sendDanmu() { |
| 78 | + this.context.sendDanmu({ |
| 79 | + text: '要显示的弹幕文本', |
| 80 | + color: '#FF0000' |
| 81 | + }); |
| 82 | + }, |
| 83 | + playbackRate() { |
| 84 | + this.context.playbackRate(2); |
| 85 | + } |
| 86 | + } |
| 87 | + } |
| 88 | +</script> |
| 89 | + |
| 90 | +<style> |
| 91 | + .video { |
| 92 | + width: 750rpx; |
| 93 | + /* #ifdef H5 */ |
| 94 | + width: 100%; |
| 95 | + /* #endif */ |
| 96 | + height: 400rpx; |
| 97 | + background-color: #808080; |
| 98 | + } |
| 99 | + |
| 100 | + .btn { |
| 101 | + margin-top: 5px; |
| 102 | + margin-bottom: 5px; |
| 103 | + } |
102 | 104 | </style>
|
0 commit comments