vue播放视频
npm install video.js
npm install aes-decrypter
npm install m3u8-parser
npm install mpd-parser
npm install mux.js
npm install url-toolkit
npm install videojs-contrib-hls
proxyTable: {
'/api': { //使用"/api"来代替"http://f.apiplus.c"
target: 'http://127.0.0.1:8000/', //源地址
changeOrigin: true, //改变源
pathRewrite: {
'^/api': '' //路径重写
}
}
},
<template>
<div id='play'>
<video id="my-video" class="video-js vjs-default-skin" controls preload="auto" >
<source :src="src" >
</video>
</div>
</template>
<script>
import videojs from 'video.js'
import 'videojs-contrib-hls'
export default {
name:'play',
data(){
return {
src:''
}
},
created(){
// 应该去后台获取播放地址,实际上模拟地址了
this.src = '/api/static/video/list.m3u8';
},
mounted(){
videojs('my-video', {
bigPlayButton: true,
textTrackDisplay: false,
posterImage: true,
errorDisplay: false,
controlBar: true
}, function () {
this.play()
})
}
}
</script>