import React, { Component } from 'react'; import './index.less'; import videojs from 'video.js'; import Assets from '@src/components/Assets'; export default class Video extends Component { constructor(props) { super(props); this.ready = false; this.state = { playing: false, fulling: false }; } componentDidMount() { this.player = videojs( this.videoNode, { controls: false, sources: [ { src: this.props.src, type: 'video/mp4', }, ], }, () => { this.ready = true; }, ); } componentWillUnmount() { if (this.player) { this.player.dispose(); } } onPlay() { if (!this.ready) return; this.player.play(); this.setState({ playing: true }); } onPuase() { if (!this.ready) return; this.player.pause(); this.setState({ playing: false }); } onSpeed(speed) { this.player.playbackRate(speed); } render() { const { action = true, btnList = [], onAction } = this.props; const { playing, fulling } = this.state; return (