| | |
| | | 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, // 条码值 |
| | | value: PropTypes.string, // 视频地址 |
| | | } |
| | | |
| | | componentDidMount () { |
| | | this.player.seek(1) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.props), fromJS(nextProps)) |
| | | shouldComponentUpdate () { |
| | | return false |
| | | } |
| | | |
| | | 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> |
| | | <Player ref={player => { this.player = player }} aspectRatio={'4:3'}> |
| | | <source src={this.props.value} /> |
| | | </Player> |
| | | ) |
| | | } |
| | | } |