vionPlayerDemo.vue
3.36 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<template>
<div class="j-player-demo">
<div class="player-content">
<!-- :play-url="playUrl" -->
<vion-player v-if="playerVisible"
ref="vionPlayer"
:datetime-range="datetimeRange"
watermarkText="文安智能123"
@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="handleShow">展示</button> -->
<button @click="handlePause">暂停</button>
<button @click="handleStop">停止</button>
<button @click="handleDestroy">销毁</button>
<button @click="handleScreenshot">抓拍</button>
<div class="record">
<input type="text" v-model="recordUrl">
<button @click="handleRecord">录像</button>
</div>
</div>
<el-dialog title="Image" :visible.sync="dialogVisible" width="90%">
<img v-if="dialogVisible" :src="base64Url" alt="base64" />
</el-dialog>
</div>
</template>
<script>
import VionPlayer from '../../components/vionPlayer';
export default {
name: 'VionPlayerDemo',
components: {
VionPlayer,
},
data() {
return {
datetimeRange: [],
playerVisible: true,
dialogVisible: false,
base64Url: '',
// 播放器相关
playUrl: 'https://rtmp01open.ys7.com:9188/v3/openlive/F16423875_1_1.flv?expire=1695279265&id=624619383494283264&t=75ae0260690eedd9d493ab1caf716fe3f10a3e4c9b6df59135e032d437cf187a&ev=100&supportH265=1',
recordUrl: 'https://rtmp01open.ys7.com:9188/v3/openpb/F16423875_1_1.flv?begin=20230919103030&end=20230919113030&expire=1695289270&id=624661345092866048&rec=local&t=53368acd4fe795901a25cc1f85e212040abd6d816d5d7154fc61cff27285b81a&ev=100&supportH265=1',
}
},
methods: {
handlePlay() {
const url = this.playUrl;
this.$refs.vionPlayer.play(url);
},
handleShow() {
this.playerVisible = true;
},
handleRecord() {
this.$refs.vionPlayer.play(this.recordUrl);
},
handleScreenshot() {
this.$refs.vionPlayer.screenshot().then(data => {
console.log('handleScreenshot', data);
this.base64Url = data;
this.dialogVisible = true;
}).catch(err => {
console.error(err);
})
},
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;
}
> div.record {
margin-top: 10px;
> button {
margin-left: 2px;
}
}
}
::v-deep(.el-dialog__body) {
text-align: center;
background-color: #CCC;
> img {
max-width: 100%;
height: auto;
}
}
}
</style>