vue在谷歌浏览器打开rtmp流
1.先启动一个vue项目
2.安装依赖
cnpm install videojs-flash --save
cnpm install vue-video-player -S
3.在main.js中全局引入
import VideoPlayer from ‘vue-video-player’
import ‘video.js/dist/video-js.css’
import ‘videojs-flash’
Vue.use(VideoPlayer)
4.在页面中填写
<template>
<div>
<video-player ref="videoPlayer" :options="videoOptions" class="vjs-custom-skin videoPlayer" :playsinline="true"></video-player>
</div>
</template>
<script>
import { videoPlayer } from 'vue-video-player'
import 'video.js/dist/video-js.css'
import 'videojs-flash'
export default {
components: {
videoPlayer
},
//完整的配置数据(不要的可以直接注释掉)
data(){
return {
videoOptions: {
live: true,
autoplay: true,
fluid: true,
notSupportedMessage: '暂时无法播放',
controlBar: {
timeDivider: true,
durationDisplay: true,
remainingTimeDisplay: false,
fullscreenToggle: true // 全屏按钮
},
techOrder: ['flash'],
sources: [{ // 流配置,数组形式,会根据兼容顺序自动切换
type: 'rtmp/mp4',
src: 'rtmp://58.200.131.2:1935/livetv/hunantv' //这是芒果TV现场直播视频,地址是可以用的,最后需要替换成后端给的项目地址
}]
}
}
},
methods:{
}
}
</script>
5.打开谷歌浏览器的flash限制