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