安装
vue-video-player 在 “
devDependencies
” 中
安装
videojs-contrib-hls 在“
dependencies
”中
main.js 中引入
import hls from ‘videojs-contrib-hls‘ import VideoPlayer from ‘vue-video-player‘; import "video.js/dist/video-js.css" import "vue-video-player/src/custom-theme.css" Vue.use(hls) Vue.use(VideoPlayer)
页面中使用 第一种方式
<video id="my-video" class="video-js vjs-default-skin" controls preload="auto"> <source src="http://ivi.bupt.edu.cn/hls/cctv1.m3u8" type="application/x-mpegURL" /> </video>
import "video.js/dist/video-js.css"; import videojs from "video.js"; import "videojs-contrib-hls";
mounted(){ videojs( "my-video", { bigPlayButton: false, textTrackDisplay: false, posterImage: true, errorDisplay: false, controlBar: true }, function() { this.play(); } ); }
页面中使用 第二种方式
<video-player class="video-player vjs-custom-skin" :playsinline="true" :options="‘http://ivi.bupt.edu.cn/hls/cctv1.m3u8‘|videoOption"> </video-player>
import ‘videojs-contrib-hls‘
filters:{ videoOption(val) { console.log(‘val‘,val) return { live: false, preload: "auto", autoplay: true, language: "zh-CN", aspectRatio: "16:8", fluid: true, sources: [ { src: val //url地址 } ], notSupportedMessage: "此视频暂无法播放,请稍后再试", //允许覆盖Video.js无法播放媒体源时显示的默认信息。 controlBar: { timeDivider: false, durationDisplay: false, remainingTimeDisplay: false, fullscreenToggle: true //全屏按钮 }, flash: { hls: { withCredentials: false } } } }, }
原文地址:https://www.cnblogs.com/Byme/p/11419131.html
时间: 2024-10-30 09:18:34