video-player.vue
1.84 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
<template>
<div class="video-player">
<video
ref="videoPlayer"
class="video-js vjs-matrix vjs-yoho"
:poster="coverImg"
controls
preload="auto"
playsinline
x5-playsinline
webkit-playsinline="true">
<source :src="source" type="video/mp4"></source>
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a
web browser
</p>
</video>
</div>
</template>
<script>
import videojs from 'video.js';
export default {
name: 'VideoPlayer',
props: {
source: String,
cover: String,
options: {
type: Object,
default() {
return {
muted: true,
controls: true,
aspectRatio: '1:1'
};
}
}
},
data() {
return {
player: null
};
},
computed: {
coverImg() {
if (this.cover) {
return this.cover.split('?')[0];
} else {
return '';
}
},
},
mounted() {
this.player = videojs(this.$refs.videoPlayer, this.options);
},
beforeDestroy() {
if (this.player) {
this.player.dispose();
}
}
};
</script>
<style lang="scss" scoped>
.video-js {
width: 100%;
height: auto;
video {
width: 100%;
}
&.vjs-yoho /deep/ {
.vjs-big-play-button {
width: 120px;
height: 120px;
line-height: 120px;
font-size: 60px;
border-radius: 50%;
left: 50%;
top: 50%;
margin: -60px auto auto -60px;
}
.vjs-control-bar {
height: 60px;
font-size: 26px;
.vjs-control {
width: 80px;
}
.vjs-time-control {
line-height: 60px;
}
.vjs-icon-placeholder:before {
font-size: 38px;
line-height: 60px;
}
}
}
}
</style>