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>

猜你喜欢

转载自www.cnblogs.com/shaoyang0123/p/11827256.html