|
@@ -57,8 +57,7 @@ export default {
|
|
|
this.initMp4Player(this.videoProp.userId, videoId, this.videoProp.coverUrl, urls, res.data.currentTime, event)
|
|
this.initMp4Player(this.videoProp.userId, videoId, this.videoProp.coverUrl, urls, res.data.currentTime, event)
|
|
|
} else if (urlType === 'flv') {
|
|
} else if (urlType === 'flv') {
|
|
|
const urls = res.data.urls
|
|
const urls = res.data.urls
|
|
|
- const url = urls[0].url
|
|
|
|
|
- this.initFlvPlayer(videoId, this.videoProp.coverUrl, url)
|
|
|
|
|
|
|
+ this.initFlvPlayer(this.videoProp.userId, videoId, this.videoProp.coverUrl, urls, res.data.currentTime, event)
|
|
|
} else {
|
|
} else {
|
|
|
this.$notify.error({
|
|
this.$notify.error({
|
|
|
message: '视频 url 类型不合法',
|
|
message: '视频 url 类型不合法',
|
|
@@ -148,8 +147,8 @@ export default {
|
|
|
console.log('声音改变')
|
|
console.log('声音改变')
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- initFlvPlayer(videoId, coverUrl, videoUrl) {
|
|
|
|
|
- new DPlayer({
|
|
|
|
|
|
|
+ initFlvPlayer(userId, videoId, coverUrl, urls, pos, event) {
|
|
|
|
|
+ const player = new DPlayer({
|
|
|
container: document.getElementById('dplayer'),
|
|
container: document.getElementById('dplayer'),
|
|
|
lang: 'zh-cn',
|
|
lang: 'zh-cn',
|
|
|
logo: '/logo.png',
|
|
logo: '/logo.png',
|
|
@@ -158,7 +157,10 @@ export default {
|
|
|
volume: 0.1,
|
|
volume: 0.1,
|
|
|
mutex: true,
|
|
mutex: true,
|
|
|
video: {
|
|
video: {
|
|
|
- url: videoUrl,
|
|
|
|
|
|
|
+ pic: coverUrl,
|
|
|
|
|
+ defaultQuality: 0,
|
|
|
|
|
+ quality: urls,
|
|
|
|
|
+ hotkey: true,
|
|
|
type: 'customFlv',
|
|
type: 'customFlv',
|
|
|
customType: {
|
|
customType: {
|
|
|
customFlv: function(video, player) {
|
|
customFlv: function(video, player) {
|
|
@@ -172,6 +174,42 @@ export default {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ // 跳转到上次看到的位置
|
|
|
|
|
+ player.seek(pos)
|
|
|
|
|
+
|
|
|
|
|
+ /* 事件绑定 */
|
|
|
|
|
+ player.on('progress', function() {
|
|
|
|
|
+ if (event) {
|
|
|
|
|
+ const payload = {}
|
|
|
|
|
+ payload.videoId = videoId
|
|
|
|
|
+ payload.currentTime = player.video.currentTime
|
|
|
|
|
+ payload.ended = false
|
|
|
|
|
+
|
|
|
|
|
+ const jsonData = {}
|
|
|
|
|
+ jsonData.event = 'progress'
|
|
|
|
|
+ jsonData.payload = JSON.stringify(payload)
|
|
|
|
|
+ SocketInstance.send(jsonData)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ player.on('ended', () => {
|
|
|
|
|
+ if (event) {
|
|
|
|
|
+ const payload = {}
|
|
|
|
|
+ payload.videoId = videoId
|
|
|
|
|
+ payload.currentTime = player.video.currentTime
|
|
|
|
|
+ payload.ended = true
|
|
|
|
|
+
|
|
|
|
|
+ const jsonData = {}
|
|
|
|
|
+ jsonData.event = 'progress'
|
|
|
|
|
+ jsonData.payload = JSON.stringify(payload)
|
|
|
|
|
+ SocketInstance.send(jsonData)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ player.on('volumechange', () => {
|
|
|
|
|
+ console.log('声音改变')
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|