video-player.vue
1.47 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
<template>
<div class="video-player">
<video
ref="videoPlayer"
class="video-js vjs-matrix vjs-yoho"
controls
preload="auto">
<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 that
</p>
</video>
</div>
</template>
<script>
import videojs from 'video.js';
export default {
name: 'VideoPlayer',
props: {
source: String,
options: {
type: Object,
default() {
return {
techOrder: ['html5', 'flash'],
muted: true,
controls: true,
aspectRatio: '1:1'
};
}
}
},
data() {
return {
player: null
};
},
mounted() {
this.player = videojs(this.$refs.videoPlayer, this.options, function onPlayerReady() {
this.play();
});
},
beforeDestroy() {
if (this.player) {
this.player.dispose();
}
}
};
</script>
<style src="video.js/dist/video-js.css"></style>
<style lang="scss" scoped>
.video-js {
width: 100%;
height: auto;
video {
width: 100%;
}
&.vjs-yoho /deep/ {
.vjs-big-play-button {
width: 70px;
height: 70px;
line-height: 70px;
border-radius: 50%;
left: 50%;
top: 50%;
margin: -35px auto auto -35px;
}
.vjs-control-bar .vjs-icon-placeholder {
font-size: 22px;
}
}
}
</style>