1、视频流播放 -- video
原生
<video width="100%" height="680" controls="controls"
controlslist="nodownload" preload="auto" style="margin-top: 10px;">
<source :src="videoPath" type="video/mp4">
</video>
let videoPath = 'http://xxx.xx.com/base/videoFileDetails/getVideos?id=40288238b'
2、视频流播放 -- vue-video-player
1、npm install vue-video-player --save
2、当前组件引入,也可以在main.js里面引入
import { videoPlayer } from 'vue-video-player'
// import 'video.js/dist/video-js.css'
require('video.js/dist/video-js.css')
import 'vue-video-player/src/custom-theme.css'
3、页面应用 -- vue-video-player
<video-player class="video-player vjs-custom-skin"
ref="videoPlayer"
:playsinline="true"
:options="playerOptions"
></video-player>
playerOptions : {
playbackRates: [0.5, 1.0, 1.5, 2.0],
autoplay: false,
muted: false,
loop: false,
preload: 'auto',
language: 'zh-CN',
aspectRatio: '16:9',
fluid: true,
sources: [{
src: '',
type: 'video/mp4'
}],
notSupportedMessage: '此视频暂无法播放,请稍后再试',
controlBar: {
timeDivider : true,
durationDisplay : true,
remainingTimeDisplay : true,
fullscreenToggle: true,
}
},
videoPath:process.env.VUE_APP_API_BASE_URL+'/base/videoFileDetails/getVideos?id='
this.playerOptions.sources[0].src = this.videoPath+id;
# 特别提醒:video src不能直接在标签上写地址,需要用变量赋值(原因暂时没研究明白)