You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.2 KiB

  1. import ImmutablePropTypes from 'react-immutable-proptypes';
  2. import PureRenderMixin from 'react-addons-pure-render-mixin';
  3. import IconButton from './icon_button';
  4. const VideoPlayer = React.createClass({
  5. propTypes: {
  6. media: ImmutablePropTypes.map.isRequired,
  7. width: React.PropTypes.number,
  8. height: React.PropTypes.number
  9. },
  10. getDefaultProps () {
  11. return {
  12. width: 196,
  13. height: 110
  14. };
  15. },
  16. getInitialState () {
  17. return {
  18. muted: true
  19. };
  20. },
  21. mixins: [PureRenderMixin],
  22. handleClick () {
  23. this.setState({ muted: !this.state.muted });
  24. },
  25. render () {
  26. return (
  27. <div style={{ cursor: 'default', marginTop: '8px', overflow: 'hidden', width: `${this.props.width}px`, height: `${this.props.height}px`, boxSizing: 'border-box', background: '#000', position: 'relative' }}>
  28. <div style={{ position: 'absolute', top: '10px', left: '10px', opacity: '0.8' }}><IconButton title='Toggle sound' icon={this.state.muted ? 'volume-up' : 'volume-off'} onClick={this.handleClick} /></div>
  29. <video src={this.props.media.get('url')} autoPlay='true' loop={true} muted={this.state.muted} style={{ width: '100%', height: '100%' }} />
  30. </div>
  31. );
  32. }
  33. });
  34. export default VideoPlayer;