vionPlayerDemo.vue
2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<template>
<div class="j-player-demo">
<div class="player-content">
<!-- :play-url="playUrl" -->
<vion-player ref="vionPlayer"
:type="playerType"
:datetime-range="datetimeRange"
watermarkText="方案智能"
@ptz-control="handlePtz"
/>
</div>
<div class="footer">
<div class="play">
<input type="text" v-model="playUrl">
<button @click="handlePlay">播放</button>
</div>
<!-- <button @click="handleLive">直播</button> -->
<!-- <button @click="handlePlayback">回放</button> -->
<button @click="handlePause">暂停</button>
<button @click="handleStop">停止</button>
<button @click="handleDestroy">销毁</button>
<!-- <button @click="handleScreenshot">抓拍</button> -->
</div>
</div>
</template>
<script>
import VionPlayer from '../../components/vionPlayer';
export default {
name: 'VionPlayerDemo',
components: {
VionPlayer,
},
data() {
return {
playerType: 'live',
datetimeRange: [],
// 播放器相关
playUrl: 'https://xyrtmp.ys7.com:9188/v3/openlive/33011015992467054043:33010285991117359447_1_1.flv?expire=1695197391&id=624275978952122369&t=5d6125d91a189547ecc984fd4f153abea9dbf72b6bc77a88c7d5e6054ae7df48&ev=100&devProto=gb28181&supportH265=1',
}
},
methods: {
handlePlay() {
const url = this.playUrl;
this.$refs.vionPlayer.play(url);
},
handleLive() {
this.playerType = 'live';
},
handlePlayback() {
this.playerType = 'playback';
this.datetimeRange = [
'1693904400000',
'1693908000000',
];
},
handleScreenshot() {
this.$refs.vionPlayer.screenshotWatermark().then(data => {
console.log('handleScreenshot', data);
});
},
handlePause() {
this.$refs.vionPlayer.pause();
},
handleStop() {
this.$refs.vionPlayer.stop();
},
handleDestroy() {
this.$refs.vionPlayer.destroy();
},
handlePtz(arrow) {
console.log('handlePtz', arrow);
},
},
}
</script>
<style lang="scss" scoped>
.j-player-demo {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
outline: 1px solid #ccc;
padding-top: 10px;
padding-bottom: 10px;
> .player-content {
width: 800px;
height: 480px;
}
> .footer {
margin-top: 10px;
> div.play {
display: inline-block;
margin-right: 10px;
> button {
margin-left: 2px;
}
}
> button {
margin-right: 10px;
}
}
}
</style>