使用方法:
npm install vue-video-player -S
在main.js里
import VideoPlayer from 'vue-video-player'
require('video.js/dist/video-js.css')
require('vue-video-player/src/custom-theme.css')
Vue.use(VideoPlayer)
在vue的组件页面里
<template>
<video-player class="video-player vjs-custom-skin"
ref="videoPlayer"
:playsinline="true"
:options="playerOptions"
></video-player>
</template>
<script>
export default {
name: 'BusImg',
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:9', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
sources: [{
type: "",
src: 'http://sante.weixinbe.com/public/supplier/1527739003138040.mp4'//url地址
// src: 'http://www.html5videoplayer.net/videos/madagascar3.mp4'//url地址
// src: "" //url地址
}],
poster: "", //你的封面地址
// width: document.documentElement.clientWidth,
notSupportedMessage: '此视频暂无法播放,请稍后再试', //允许覆盖Video.js无法播放媒体源时显示的默认信息。
controlBar: {
timeDivider: true,
durationDisplay: true,
remainingTimeDisplay: false,
fullscreenToggle: true //全屏按钮
}
}
</script>
.video-js .vjs-big-play-button{}
(1)发现很多的视频格式是无法播放的
sources: [
{
// type: "video/webm", // ok,用ogg也可打开
type: "video/ogg", // ok,用webm也可打开
// type: "video/3gp", //ok
// type: "video/mp4", // ok
// type: "video/avi", //打不开
// type: "video/flv", // 打不开
// type: "video/mkv", // 打不开
// type: "video/mov", // 打不开
// type: "video/mpg", // 打不开
// type: "video/swf", // 打不开
// type: "video/ts", // 打不开
// type: "video/wmv", // 打不开
// type: "video/vob", // 没转化
// type: "video/mxf", // 转化出错
// type: "video/rm", // 转化出错
src: '/static/video/Video_2018-05-15_105711.webm'//本地测试url地址
// src: 'http://www.html5videoplayer.net/videos/madagascar3.mp4'//url地址
}
],
以上为我对一些格式的测试
在线视频文件格式转化工具:https://cloudconvert.com/wmv-to-mp4
在线播放MP4链接示例:http://www.html5videoplayer.net/videos/madagascar3.mp4
1.vue 调用视频播放插件:https://blog.csdn.net/believeXin/article/details/79269718
2.vue-video-player插件官方例子:https://github.com/surmon-china/vue-video-player/blob/master/examples/01-video.vue
3.vue使用vue-video-player在直播中的应用(暂未实践):https://www.cnblogs.com/xuejiangjun/p/8673856.html
4.vue2.0+vue-dplayer实现hls播放(暂未实践):https://blog.csdn.net/fei565789229/article/details/78933724