jPlayerDemo.vue
1.57 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
<template>
<div class="j-player-demo">
<div class="player-content">
<j-player ref="jplay"
:type="playerType"
prefix-url=""
channel-id="20000000001310000011"
:datetime-range="datetimeRange"
/>
</div>
<div class="footer">
<button @click="handleLive">直播</button>
<button @click="handlePlayback">回放</button>
<button @click="handleStop">停止</button>
<button @click="handleScreenshot">抓拍</button>
</div>
</div>
</template>
<script>
import JPlayer from '../../components/jPlayer';
export default {
name: 'JPlayerDemo',
data() {
return {
playerType: 'live',
datetimeRange: [],
}
},
components: {
JPlayer,
},
methods: {
handleLive() {
this.playerType = 'live';
},
handlePlayback() {
this.playerType = 'playback';
this.datetimeRange = [
'1693904400000',
'1693908000000',
];
},
handleScreenshot() {
const imgData = this.$refs.jplay.screenshot();
console.log('handleScreenshot', imgData);
},
handleStop() {
const result = this.$refs.jplay.stopPlay();
console.log('handleStop', result);
},
},
}
</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;
> button {
margin-right: 10px;
}
}
}
</style>