本文实例为大家分享了vue-video-player视频播放器的使用配置,供大家参考,具体内容如下
1、安装
1
|
npm install vue-video-player -save
|
2、在main.js中添加
1
2
3
4
|
import VueVideoPlayer from 'vue-video-player' // 视频播放器
import 'video.js/dist/video-js.css'
Vue.use(VueVideoPlayer)
|
3、新建一个vueVideoPlayer.vue组件供调用
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
<template>
<div id= "vueVideoPlayer" >
<video-player class= "video-player vjs-custom-skin" ref= "videoPlayer" :playsinline= "true" :options= "playerOptions" ></video-player>
</div>
</template>
<script>
export default {
name: 'vueVideoPlayer' ,
props: {
src: {
type: String
},
cover_url: {
type: String
}
},
data () {
return {
// 配置信息
playerOptions: {
playbackRates: [0.7, 1.0, 1.5, 2.0], // 播放速度
autoplay: false , // 如果true,浏览器准备好时开始回放。
muted: false , // 默认情况下将会消除任何音频。
loop: false , // 导致视频一结束就重新开始。
preload: 'auto' , // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频(如果浏览器支持)
language: 'zh-CN' ,
aspectRatio: '16:10' , // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
fluid: true , // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
sources: [{
src: this .src, // 路径
type: 'video/mp4' // 类型
}],
poster: this .cover_url, // 你的封面地址
// width: document.documentElement.clientWidth,
notSupportedMessage: '此视频暂无法播放,请稍后再试' , // 允许覆盖Video.js无法播放媒体源时显示的默认信息。
controlBar: {
timeDivider: true ,
durationDisplay: true ,
remainingTimeDisplay: false ,
fullscreenToggle: true // 全屏按钮
}
}
}
}
}
|
4、在其他组件调用
1
2
3
4
5
6
7
|
<vueVideoPlayer :src= "data.url" :cover_url= "data.cover_url" />
import vueVideoPlayer from './module/vueVideoPlayer'
// 不要忘记注册
components: {
vueVideoPlayer
}
|
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/qq_39905409/article/details/98481735