|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
<template>
|
|
|
<el-row v-if="!permissionDenied" class="movie-list">
|
|
<el-row v-if="!permissionDenied" class="movie-list">
|
|
|
- <el-col :md="15">
|
|
|
|
|
|
|
+ <el-col v-if="video !== null" :md="15">
|
|
|
<el-row style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
|
|
<el-row style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
|
|
|
<el-card class="box-card">
|
|
<el-card class="box-card">
|
|
|
<div slot="header" class="clearfix">
|
|
<div slot="header" class="clearfix">
|
|
@@ -139,46 +139,31 @@
|
|
|
</div>
|
|
</div>
|
|
|
<div class="text item">
|
|
<div class="text item">
|
|
|
<el-table
|
|
<el-table
|
|
|
- :data="similarVideos"
|
|
|
|
|
|
|
+ :data="playList.list"
|
|
|
|
|
+ :show-header="false"
|
|
|
|
|
+ height="480"
|
|
|
style="width: 100%"
|
|
style="width: 100%"
|
|
|
>
|
|
>
|
|
|
<el-table-column
|
|
<el-table-column
|
|
|
prop="title"
|
|
prop="title"
|
|
|
>
|
|
>
|
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
|
- <router-link target="_blank" :to="`/video/${scope.row.videoId}`">
|
|
|
|
|
- <span>{{ scope.row.videoId }}</span>
|
|
|
|
|
|
|
+ <router-link :to="`/vidlist/${scope.row.videoId}`">
|
|
|
|
|
+ <span>{{ scope.row.title | ellipsis }}</span>
|
|
|
</router-link>
|
|
</router-link>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column
|
|
<el-table-column
|
|
|
- prop="coverUrl"
|
|
|
|
|
|
|
+ prop="duration"
|
|
|
>
|
|
>
|
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
|
- <span>10:00</span>
|
|
|
|
|
|
|
+ <span>{{ scope.row.duration }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
</el-table>
|
|
</el-table>
|
|
|
</div>
|
|
</div>
|
|
|
</el-card>
|
|
</el-card>
|
|
|
</el-row>
|
|
</el-row>
|
|
|
- <el-row style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
|
|
|
|
|
- <el-card class="box-card">
|
|
|
|
|
- <div slot="header" class="clearfix">
|
|
|
|
|
- <el-row>
|
|
|
|
|
- <h3>推荐视频</h3>
|
|
|
|
|
- </el-row>
|
|
|
|
|
- <el-row>
|
|
|
|
|
- <span>自动播放 <el-switch v-model="autoPlay" /></span>
|
|
|
|
|
- </el-row>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div class="text item">
|
|
|
|
|
- <el-row v-for="(item,index) in similarVideos" :key="index" class="item">
|
|
|
|
|
- <video-card :video="item" />
|
|
|
|
|
- </el-row>
|
|
|
|
|
- </div>
|
|
|
|
|
- </el-card>
|
|
|
|
|
- </el-row>
|
|
|
|
|
</el-row>
|
|
</el-row>
|
|
|
</el-col>
|
|
</el-col>
|
|
|
|
|
|
|
@@ -239,7 +224,6 @@
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
import PermissionDeniedCard from '@/components/card/PermissionDeniedCard'
|
|
import PermissionDeniedCard from '@/components/card/PermissionDeniedCard'
|
|
|
-import VideoCard from 'components/card/VideoCard'
|
|
|
|
|
import UserAvatarCard from '@/components/card/UserAvatarCard'
|
|
import UserAvatarCard from '@/components/card/UserAvatarCard'
|
|
|
import comment from '@/components/comment'
|
|
import comment from '@/components/comment'
|
|
|
import SocketInstance from '@/utils/ws/socket-instance'
|
|
import SocketInstance from '@/utils/ws/socket-instance'
|
|
@@ -254,7 +238,17 @@ import { submitAccessCode } from '@/api/content'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
name: 'VideoList',
|
|
name: 'VideoList',
|
|
|
- components: { VideoCard, UserAvatarCard, PermissionDeniedCard, comment },
|
|
|
|
|
|
|
+ components: { UserAvatarCard, PermissionDeniedCard, comment },
|
|
|
|
|
+ filters: {
|
|
|
|
|
+ ellipsis(value) {
|
|
|
|
|
+ if (!value) return ''
|
|
|
|
|
+ const max = 20
|
|
|
|
|
+ if (value.length > max) {
|
|
|
|
|
+ return value.slice(0, max) + '...'
|
|
|
|
|
+ }
|
|
|
|
|
+ return value
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
/** ********************************************************************/
|
|
/** ********************************************************************/
|
|
@@ -281,7 +275,6 @@ export default {
|
|
|
// **********************************************************************/
|
|
// **********************************************************************/
|
|
|
video: null,
|
|
video: null,
|
|
|
user: null,
|
|
user: null,
|
|
|
- similarVideos: [],
|
|
|
|
|
isCollected: false,
|
|
isCollected: false,
|
|
|
showAccessCodeDialog: false,
|
|
showAccessCodeDialog: false,
|
|
|
accessCodeForm: {
|
|
accessCodeForm: {
|
|
@@ -299,7 +292,7 @@ export default {
|
|
|
content: '视频',
|
|
content: '视频',
|
|
|
route: '/video'
|
|
route: '/video'
|
|
|
},
|
|
},
|
|
|
- showPlaylist: false,
|
|
|
|
|
|
|
+ showPlaylist: true,
|
|
|
autoPlay: false,
|
|
autoPlay: false,
|
|
|
playList: {
|
|
playList: {
|
|
|
current: 0,
|
|
current: 0,
|
|
@@ -331,15 +324,30 @@ export default {
|
|
|
const videoId = this.$route.params.id
|
|
const videoId = this.$route.params.id
|
|
|
this.accessCodeForm.contentId = videoId
|
|
this.accessCodeForm.contentId = videoId
|
|
|
this.getVideoInfo(videoId)
|
|
this.getVideoInfo(videoId)
|
|
|
- this.getSimilarVideos(videoId)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ const key = 'myplaylist-' + videoId
|
|
|
|
|
+ const value = localStorage.getItem(key)
|
|
|
|
|
+ if (value != null) {
|
|
|
|
|
+ this.playList = JSON.parse(value)
|
|
|
|
|
+ this.calculateCurrent(videoId)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.getSimilarVideos(videoId)
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
mounted() {
|
|
mounted() {
|
|
|
|
|
+ window.addEventListener('beforeunload', this.handleBeforeUnload)
|
|
|
const header = this.$refs.header
|
|
const header = this.$refs.header
|
|
|
- if (header !== null) {
|
|
|
|
|
|
|
+ if (header !== undefined && header !== null) {
|
|
|
|
|
+ console.log('header -> ' + header)
|
|
|
this.wrapStyle = `height: calc(100vh - ${header.clientHeight + 20}px)`
|
|
this.wrapStyle = `height: calc(100vh - ${header.clientHeight + 20}px)`
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ handleBeforeUnload(event) {
|
|
|
|
|
+ const key = 'myplaylist-' + this.video.videoId
|
|
|
|
|
+ localStorage.removeItem(key)
|
|
|
|
|
+ // event.preventDefault()
|
|
|
|
|
+ },
|
|
|
// 获取视频的详细信息
|
|
// 获取视频的详细信息
|
|
|
getVideoInfo(videoId) {
|
|
getVideoInfo(videoId) {
|
|
|
videoInfo(videoId).then(resp => {
|
|
videoInfo(videoId).then(resp => {
|
|
@@ -378,8 +386,8 @@ export default {
|
|
|
getSimilarVideos(videoId) {
|
|
getSimilarVideos(videoId) {
|
|
|
similarVideo(videoId).then(resp => {
|
|
similarVideo(videoId).then(resp => {
|
|
|
if (resp.code === 0) {
|
|
if (resp.code === 0) {
|
|
|
- // this.similarVideos = resp.data
|
|
|
|
|
this.playList.list = resp.data
|
|
this.playList.list = resp.data
|
|
|
|
|
+ this.calculateCurrent(videoId)
|
|
|
} else {
|
|
} else {
|
|
|
this.$notify.error({
|
|
this.$notify.error({
|
|
|
message: '推荐视频数据获取失败',
|
|
message: '推荐视频数据获取失败',
|
|
@@ -507,8 +515,7 @@ export default {
|
|
|
for (const url of urls) {
|
|
for (const url of urls) {
|
|
|
url.type = 'normal'
|
|
url.type = 'normal'
|
|
|
}
|
|
}
|
|
|
- const autoPlay = false
|
|
|
|
|
- this.initMp4Player(this.video.userId, videoId, this.video.coverUrl, urls, res.data.currentTime, autoPlay)
|
|
|
|
|
|
|
+ this.initMp4Player(this.video.userId, videoId, this.video.coverUrl, urls, res.data.currentTime)
|
|
|
} else {
|
|
} else {
|
|
|
this.$notify.error({
|
|
this.$notify.error({
|
|
|
message: '视频 url 类型不合法',
|
|
message: '视频 url 类型不合法',
|
|
@@ -531,13 +538,13 @@ export default {
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- initMp4Player(userId, videoId, coverUrl, urls, pos, autoPlay) {
|
|
|
|
|
|
|
+ initMp4Player(userId, videoId, coverUrl, urls, pos) {
|
|
|
const player = new DPlayer({
|
|
const player = new DPlayer({
|
|
|
container: document.querySelector('#dplayer'),
|
|
container: document.querySelector('#dplayer'),
|
|
|
lang: 'zh-cn',
|
|
lang: 'zh-cn',
|
|
|
logo: '/logo.png',
|
|
logo: '/logo.png',
|
|
|
screenshot: false,
|
|
screenshot: false,
|
|
|
- autoplay: autoPlay,
|
|
|
|
|
|
|
+ autoplay: true,
|
|
|
volume: 0.1,
|
|
volume: 0.1,
|
|
|
mutex: true,
|
|
mutex: true,
|
|
|
video: {
|
|
video: {
|
|
@@ -575,28 +582,44 @@ export default {
|
|
|
jsonData.videoId = videoId
|
|
jsonData.videoId = videoId
|
|
|
jsonData.currentTime = player.video.currentTime
|
|
jsonData.currentTime = player.video.currentTime
|
|
|
SocketInstance.send(jsonData)
|
|
SocketInstance.send(jsonData)
|
|
|
-
|
|
|
|
|
- const nextPath = this.getNextPath()
|
|
|
|
|
- if (nextPath !== null) {
|
|
|
|
|
- console.log('播放下一个视频')
|
|
|
|
|
- this.$router.push(nextPath)
|
|
|
|
|
- } else {
|
|
|
|
|
- console.log('视频播放完成')
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.getNextPath(videoId)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
player.on('volumechange', () => {
|
|
player.on('volumechange', () => {
|
|
|
console.log('声音改变')
|
|
console.log('声音改变')
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- getNextPath() {
|
|
|
|
|
- let current = this.playList.current
|
|
|
|
|
- if (current !== this.playList.list.length) {
|
|
|
|
|
- current += 1
|
|
|
|
|
- return this.playList.list[current]
|
|
|
|
|
|
|
+ calculateCurrent(videoId) {
|
|
|
|
|
+ for (var i = 0; i < this.playList.list.length; i++) {
|
|
|
|
|
+ if (videoId === this.playList.list[i].videoId) {
|
|
|
|
|
+ this.playList.current = i
|
|
|
|
|
+ const key = 'myplaylist-' + this.video.videoId
|
|
|
|
|
+ localStorage.setItem(key, JSON.stringify(this.playList))
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ setCurrent(current) {
|
|
|
|
|
+ this.playList.current = current
|
|
|
|
|
+ const key = 'myplaylist-' + this.video.videoId
|
|
|
|
|
+ localStorage.setItem(key, JSON.stringify(this.playList))
|
|
|
|
|
+ },
|
|
|
|
|
+ getNextPath(current) {
|
|
|
|
|
+ this.calculateCurrent(current)
|
|
|
|
|
+ const next = this.playList.current + 1
|
|
|
|
|
+ if (next < this.playList.list.length) {
|
|
|
|
|
+ this.setCurrent(next)
|
|
|
|
|
+ const videoId = this.playList.list[next].videoId
|
|
|
|
|
+ const path = '/vidlist/' + videoId
|
|
|
|
|
+ if (path !== this.$route.path) {
|
|
|
|
|
+ this.$router.push(path)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.log(this.playList)
|
|
|
|
|
+ this.$notify.info({
|
|
|
|
|
+ message: '视频列表播放完成',
|
|
|
|
|
+ duration: 3000
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- return null
|
|
|
|
|
},
|
|
},
|
|
|
// ****************************************************************************************************************
|
|
// ****************************************************************************************************************
|
|
|
async submit(newComment, parent, add) {
|
|
async submit(newComment, parent, add) {
|