React video.js实现m3u8格式视频播放及实时切换

先安装:

npm install --save video.js

 

导入

import videojs from 'video.js'
 
import "video.js/dist/video-js.css";
 
  constructor(props) {
        super(props);
        this.state = {
            current_url : '/001.m3u8',
        }
        this.player= null
    }
 
 
componentDidMount   方法下
 this.player = videojs("video");
 this.player.controls(true)
 this.player.src(this.state.current_url)
 
<video id="video" className="video-js vjs-default-skin video" style={{height:"500px"}} ></video>

posted on 2019-11-09 18:30  少杨  阅读(3494)  评论(0)    收藏  举报