king
2021-01-28 86b366cac525ad676da3cfd65f67a551b9260aeb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Player } from 'video-react'
 
import './index.scss'
 
class Video extends Component {
  static propTpyes = {
    card: PropTypes.object,  // 条码设置
    value: PropTypes.any,    // 条码值
  }
 
  componentDidMount () {
    this.player.seek(1)
  }
 
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.props), fromJS(nextProps))
  }
 
  render() {
    const { value, card } = this.props
 
    return (
      <div style={{overflow: 'hidden'}}>
        <Player poster="" ref={player => { this.player = player }} autoPlay={card.autoPlay === 'true'} aspectRatio={card.aspectRatio || '16:9'}>
          <source src={value} />
        </Player>
      </div>
    )
  }
}
 
export default Video