|
|
@@ -79,7 +79,7 @@ export default {
|
|
|
danmaku: {
|
|
|
id: videoId,
|
|
|
maximum: 10000,
|
|
|
- api: 'api.reghao.cn/api/media/danmaku/',
|
|
|
+ api: '//api.reghao.cn/api/media/danmaku/',
|
|
|
token: 'hertube',
|
|
|
user: this.userId,
|
|
|
bottom: '15%',
|
|
|
@@ -90,34 +90,135 @@ export default {
|
|
|
// 跳转到指定秒
|
|
|
// dp.seek(100)
|
|
|
|
|
|
+ const playRecord1 = {
|
|
|
+ 'userId': 110110,
|
|
|
+ 'videoId': videoId,
|
|
|
+ 'currentTime': 0.0
|
|
|
+ }
|
|
|
+
|
|
|
player.on('play', function() {
|
|
|
- console.log(videoId + ' 播放开始' + player.video.currentTime)
|
|
|
+ playRecord1.currentTime = player.video.currentTime
|
|
|
+ submitPlayRecord(playRecord1)
|
|
|
+ .then(res => {
|
|
|
+ // eslint-disable-next-line no-empty
|
|
|
+ if (res.code === 0) {
|
|
|
+ } else {
|
|
|
+ this.$notify({
|
|
|
+ title: res.code,
|
|
|
+ message: res.msg,
|
|
|
+ type: 'warning',
|
|
|
+ duration: 500
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error(error.message)
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
player.on('pause', function() {
|
|
|
- console.log(videoId + ' 播放暂停' + player.video.currentTime)
|
|
|
+ playRecord1.currentTime = player.video.currentTime
|
|
|
+ submitPlayRecord(playRecord1)
|
|
|
+ .then(res => {
|
|
|
+ // eslint-disable-next-line no-empty
|
|
|
+ if (res.code === 0) {
|
|
|
+ } else {
|
|
|
+ this.$notify({
|
|
|
+ title: res.code,
|
|
|
+ message: res.msg,
|
|
|
+ type: 'warning',
|
|
|
+ duration: 500
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error(error.message)
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
player.on('ended', function() {
|
|
|
// TODO 当前视频播放完成后判断是否继续播放相关推荐中的视频
|
|
|
- console.log(videoId + ' 播放结束' + player.video.currentTime)
|
|
|
+ playRecord1.currentTime = player.video.currentTime
|
|
|
+ submitPlayRecord(playRecord1)
|
|
|
+ .then(res => {
|
|
|
+ // eslint-disable-next-line no-empty
|
|
|
+ if (res.code === 0) {
|
|
|
+ } else {
|
|
|
+ this.$notify({
|
|
|
+ title: res.code,
|
|
|
+ message: res.msg,
|
|
|
+ type: 'warning',
|
|
|
+ duration: 500
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error(error.message)
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
player.on('seeking', function() {
|
|
|
- console.log(videoId + ' seeking 事件 ' + player.video.currentTime)
|
|
|
+ playRecord1.currentTime = player.video.currentTime
|
|
|
+ submitPlayRecord(playRecord1)
|
|
|
+ .then(res => {
|
|
|
+ // eslint-disable-next-line no-empty
|
|
|
+ if (res.code === 0) {
|
|
|
+ } else {
|
|
|
+ this.$notify({
|
|
|
+ title: res.code,
|
|
|
+ message: res.msg,
|
|
|
+ type: 'warning',
|
|
|
+ duration: 500
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error(error.message)
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
player.on('seeked', function() {
|
|
|
- console.log(videoId + ' seeked 事件' + player.video.currentTime)
|
|
|
+ playRecord1.currentTime = player.video.currentTime
|
|
|
+ submitPlayRecord(playRecord1)
|
|
|
+ .then(res => {
|
|
|
+ // eslint-disable-next-line no-empty
|
|
|
+ if (res.code === 0) {
|
|
|
+ } else {
|
|
|
+ this.$notify({
|
|
|
+ title: res.code,
|
|
|
+ message: res.msg,
|
|
|
+ type: 'warning',
|
|
|
+ duration: 500
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error(error.message)
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
- const interval = 5
|
|
|
var i = 0
|
|
|
player.on('progress', function() {
|
|
|
console.log('i = ' + i)
|
|
|
- if (i % interval === 0) {
|
|
|
- // TODO 每 5s 向后端报告一次播放进度
|
|
|
- console.log(videoId + ' 播放进度 ' + player.video.currentTime)
|
|
|
+ if (i % 5 === 0) {
|
|
|
+ playRecord1.currentTime = player.video.currentTime
|
|
|
+ submitPlayRecord(playRecord1)
|
|
|
+ .then(res => {
|
|
|
+ // eslint-disable-next-line no-empty
|
|
|
+ if (res.code === 0) {
|
|
|
+ console.log('播放进度已发送: ' + i)
|
|
|
+ } else {
|
|
|
+ this.$notify({
|
|
|
+ title: res.code,
|
|
|
+ message: res.msg,
|
|
|
+ type: 'warning',
|
|
|
+ duration: 500
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error(error.message)
|
|
|
+ })
|
|
|
}
|
|
|
i++
|
|
|
})
|
|
|
@@ -140,6 +241,7 @@ export default {
|
|
|
api: '//api.reghao.cn/api/media/danmaku/',
|
|
|
token: 'hertube',
|
|
|
user: this.userId,
|
|
|
+ videoId: videoId,
|
|
|
bottom: '15%',
|
|
|
unlimited: true
|
|
|
}
|