今天的主要内容包括:在前台显示后台上传的视频、在前台播放后台上传的视频等,今天的内容比较简单,很轻松。下面就开始今天的学习!




<template>
<div style="padding: 10px">
<el-card>
<div v-for="item in videos" :key="item.id" style="margin: 10px 0; padding: 10px 0; color: #666; border-bottom: 1px dashed #ccc">
<span style="font-size: 14px; cursor: pointer" class="item" @click="detail(item.id)">{{ item.name }}span>
<span style="float: right; font-size: 12px; margin-top: 10px">文件大小:{{ item.size }} kbspan>
div>
el-card>
div>
template>
<script>
export default {
name: "Video",
data() {
return {
videos: []
}
},
created() {
this.request("/echarts/file/front/all").then(res => {
console.log(res.data)
this.videos = res.data.filter(v => v.type === 'mp4')
})
},
methods: {
}
}
script>
<style>
.item:hover{
color: #3a8ee6;
background: none;
}
style>









<template>
<div>
<div class='demo'>
<video-player class="video-player-box"
ref="videoPlayer"
:playsinline="true"
:options="playerOptions">
video-player>
div>
div>
template>
<script>
import 'video.js/dist/video-js.css'
import { videoPlayer } from 'vue-video-player'
export default {
name: "VideoDetail",
components: {
videoPlayer
},
data() {
return {
playerOptions: {
playbackRates: [0.5, 1.0, 1.5, 2.0], // 可选的播放速度
autoplay: true, // 如果为true,浏览器准备好时开始回放。
muted: false, // 默认情况下将会消除任何音频。
loop: false, // 是否视频一结束就重新开始。
preload: 'auto', // 建议浏览器在
language: 'zh-CN',
aspectRatio: '16:9', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
sources: [{
type: "video/mp4", // 类型
src: '' // url地址
}],
poster: '', // 封面地址
notSupportedMessage: '此视频暂无法播放,请稍后再试', // 允许覆盖Video.js无法播放媒体源时显示的默认信息。
controlBar: {
timeDivider: true, // 当前时间和持续时间的分隔符
durationDisplay: true, // 显示持续时间
remainingTimeDisplay: true, // 是否显示剩余时间功能
fullscreenToggle: true // 是否显示全屏按钮
}
}
}
},
created() {
let id = this.$route.query.id
this.request("/file/detail/" + id).then(res => {
console.log(res.data)
this.playerOptions.sources[0].src = res.data.url
})
},
methods: {}
}
script>
<style>
style>

以上就是今天学习的全部内容了,明天将为大家带来本系列的最后一篇博文,关于SpringBoot和Vue集成Markdown和多级评论的相关内容。明天见!