play.vue
6.4 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<template>
<div class="info">
<div class="container">
<div class="play">
<el-row>
<el-col :span="24">
<video-player
id="video"
class="video-player vjs-custom-skin"
ref="videoPlayer"
@ended="videoEnded"
@timeupdate="videoTimeUp"
@loadeddata="videoLoaded"
@seeking="videoSeeking"
@seeked="videoSeeked"
:events="['seeking', 'seeked']"
:playsinline="true"
:options="playerOptions"
></video-player>
<!-- <h3 id="text-progress">{{ this.progress }}</h3> -->
</el-col>
<!-- <el-col :span="6" class="text"> -->
<!-- </el-col> -->
</el-row>
</div>
</div>
</div>
</template>
<script>
import Vue from 'vue'
import VideoPlayer from 'vue-video-player'
import 'video.js/dist/video-js.css'
import 'vue-video-player/src/custom-theme.css'
Vue.use(VideoPlayer)
export default {
data() {
return {
classHour : [],
data : [],
userId :'',
videoInformation : [],
progress : '0.00%',
durationTime : '' ,// 视频总时常
currentTime : '' ,// 当前播放进度时长
saveDurationTime : '', // 视频总时常
saveCurrentTime:'', // 当前播放进度时长
isShowSubs: false,
recodrTime :null,
playerOptions:{
playbackRates: [0.7, 1.0, 1.5, 2.0], //播放速度
autoplay: false, //如果true,浏览器准备好时开始回放。
muted: false, // 默认情况下将会消除任何音频。
loop: false, // 导致视频一结束就重新开始。
preload: 'auto', // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频(如果浏览器支持)
language: 'zh-CN',
aspectRatio: '16:9', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
sources: [
{
type: 'video/mp4', //这里的种类支持很多种:基本视频格式、直播、流媒体等,具体可以参看git网址项目
src: 'http://vjs.zencdn.net/v/oceans.mp4' //url地址
}
],
poster: '', //你的封面地址
// width: document.documentElement.clientWidth, //播放器宽度
notSupportedMessage: '此视频暂无法播放,请稍后再试', //允许覆盖Video.js无法播放媒体源时显示的默认信息。
controlBar: {
timeDivider: true,
durationDisplay: true,
remainingTimeDisplay: false,
fullscreenToggle: true //全屏按钮
}
}
}
},
created() {
},
methods: {
// 视频信息加载完成,获取总时长,若接口返回进度,断点播放
videoLoaded(item) {
this.durationTime = item.cache_.duration
this.videoInformation = item
// console.log('progress', this.progress)
if (this.progress > '0.00%') {
item.currentTime(Number(this.currentTime))
}
// console.log('视频信息videoLoaded:', this.videoInformation)
},
// 当前播放进度
videoTimeUp(item) {
this.currentTime = item.cache_.currentTime
this.progress = ((this.currentTime.toFixed(2) / item.cache_.duration.toFixed(2)) * 100).toFixed(2) + '%'
// console.log('当前播放进度', item)
},
// 正在拖动
videoSeeking(item) {
// console.log('正在拖动',item)
this.isSeeking = true
},
// 拖动结束
videoSeeked(item) {
// console.log('拖动结束',item)
this.isSeeking = false
},
// 点击播放
videoPlay() {
//清除定时器
if (this.pauseTimer) {
clearTimeout(this.pauseTimer)
}
},
// 触发暂停
videoPause(item) {
//利用定时器延迟
this.pauseTimer = setTimeout(() => {
if (this.isVideoEnd) return
if (this.isSeeking) return
// 展示蒙层
this.isShowSubs = true
}, 100)
},
// 播放结束
videoEnded() {
this.isVideoEnd = true
}
}
}
</script>
<style lang="scss" scoped>
$width: 1140px;
.info {
width: 100%;
}
.container {
width: $width;
margin: auto;
.breadcrumb {
padding-top: 20px;
padding-bottom: 20px;
}
.play {
box-shadow: 0 4px 8px 0 rgba(28, 31, 33, 0.1);
background-color: #26262b;
.text {
font-size: 15px;
color: #fff;
text-align: left;
.title {
padding: 12px 15px;
}
.teacher {
padding: 12px 0 12px 10px;
background: #2d2d2d;
}
.list {
height: 393px;
width: 283px;
.name1 {
cursor: pointer;
background: #2d2d2d;
font-size: 15px;
padding: 10px 0 10px 47px;
margin-top: 2px;
}
.name2 {
cursor: pointer;
color: rgb(61, 231, 112);
background: #2d2d2d;
font-size: 15px;
padding: 10px 0 10px 47px;
margin-top: 2px;
}
}
}
}
// .biref {
// box-shadow: 0 4px 8px 0 rgba(28, 31, 33, 0.1);
// background-color: #ffffff;
// font-size: 15px;
// text-align: left;
// color: #5e5e5e;
// padding: 25px 20px;
// margin: 30px 0;
// img {
// vertical-align: middle;
// margin-right: 5px;
// }
// }
}
</style>
<style>
body {
background-color: #f7f9fc !important;
/* background-color: #d7e4f7 !important; */
}
.vjs-custom-skin > .video-js .vjs-big-play-button {
width: 70px;
border-radius: 50%;
}
.el-breadcrumb__inner {
color: #2c3e50 !important;
}
.el-scrollbar__wrap {
overflow: hidden;
position: relative;
}
</style>