We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
npm install vue-video-player --save
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)
踩坑如下:
我们如果按照官网上的方式如上代码所示引入,会报错找不到video.js/dist/video-js.css。 这里我们只需要将引入video-js.css的路径改为vue-video-player/node_modules/video.js/dist/video-js.css。
video.js/dist/video-js.css
video-js.css
vue-video-player/node_modules/video.js/dist/video-js.css
<video-player class="video-player vjs-custom-skin" ref="videoPlayer" :playsinline="true" :options="playerOptions" ></video-player>
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: "",//这里的种类支持很多种:基本视频格式、直播、流媒体等,具体可以参看git网址项目 src: "" //url地址 }], poster: "../../static/images/test.jpg", //你的封面地址 // width: document.documentElement.clientWidth, //播放器宽度 notSupportedMessage: '此视频暂无法播放,请稍后再试', //允许覆盖Video.js无法播放媒体源时显示的默认信息。 controlBar: { timeDivider: true, durationDisplay: true, remainingTimeDisplay: false, fullscreenToggle: true //全屏按钮 } }
如: // 调整播放器样式 .video-js .vjs-icon-placeholder { width: 100%; height: 100%; display: block; }
效果图如下:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
一、安装
二、在
main.js
入口文件中引入踩坑如下:
三、在页面中引用
四、配置数据
五、具体其他的按钮样式可以在外部css中设置
效果图如下:
参考文献
The text was updated successfully, but these errors were encountered: