<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import * as actions from 'actions/playerActions';
import YouTube from 'react-youtube';

class Player extends React.Component {
  static propTypes = {
    video:  PropTypes.object,
    player: PropTypes.object
  };

  constructor(props) {
    super(props);
    this.interval = null;
    this.provider = null;
  }

  shouldComponentUpdate(nextProps) {
    // return nextProps.player.time === this.props.player.time;
    return true;
  }

  componentDidUpdate(prevProps) {
    if (this.provider) {
      if (this.shouldSeekTo()) {
        this.provider.seekTo(this.props.player.time);
      }
      if (prevProps.player.status !== this.props.player.status) {
        switch (this.props.player.status) { // eslint-disable-line
          case 1:
            this.provider.playVideo();
            break;
          case 2:
            this.provider.pauseVideo();
            break;
        }
      }
      if (this.props.player.isMuted) {
        this.provider.mute();
      } else {
        this.provider.unMute();
      }
    }
  }

  componentWillUnmount() {
    clearInterval(this.interval);
  }

  shouldSeekTo = () => {
    const diff = this.props.player.time - this.provider.getCurrentTime();
    return diff > 5;
  };

  handleInterval = () => {
    const time = parseInt(this.provider.getCurrentTime(), 10);
    this.props.dispatch(actions.playerTime(time));
  };

  handleReady = (e) => {
    this.provider = e.target;

    const duration = parseInt(this.provider.getDuration(), 10);
    this.props.dispatch(actions.playerReady(duration));
    // this.provider.seekTo(this.props.player.time);
    setInterval(this.handleInterval, 1000);
  };

  handleStateChange = () => {
    const status = this.provider.getPlayerState();
    this.props.dispatch(actions.playerStatus(status));
  };

  renderProviderYoutube() {
    const opts    = {
      width:      '100%',
      playerVars: {
        widget_referrer: document.location.href,
        start:           this.props.video.start,
        showinfo:        0,
        controls:        0,
        autoplay:        1,
        rel:             0
      }<commit_msg>Disables progress bar (for now)<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import * as actions from 'actions/playerActions';
import YouTube from 'react-youtube';

class Player extends React.Component {
  static propTypes = {
    video:  PropTypes.object,
    player: PropTypes.object
  };

  constructor(props) {
    super(props);
    this.interval = null;
    this.provider = null;
  }

  shouldComponentUpdate(nextProps) {
    // return nextProps.player.time === this.props.player.time;
    return true;
  }

  componentDidUpdate(prevProps) {
    if (this.provider) {
      if (this.shouldSeekTo()) {
        this.provider.seekTo(this.props.player.time);
      }
      if (prevProps.player.status !== this.props.player.status) {
        switch (this.props.player.status) { // eslint-disable-line
          case 1:
            this.provider.playVideo();
            break;
          case 2:
            this.provider.pauseVideo();
            break;
        }
      }
      if (this.props.player.isMuted) {
        this.provider.mute();
      } else {
        this.provider.unMute();
      }
    }
  }

  componentWillUnmount() {
    clearInterval(this.interval);
  }

  shouldSeekTo = () => {
    const diff = this.props.player.time - this.provider.getCurrentTime();
    return diff > 5;
  };

  handleInterval = () => {
    const time = parseInt(this.provider.getCurrentTime(), 10);
    this.props.dispatch(actions.playerTime(time));
  };

  handleReady = (e) => {
    this.provider = e.target;

    const duration = parseInt(this.provider.getDuration(), 10);
    this.props.dispatch(actions.playerReady(duration));
    // this.provider.seekTo(this.props.player.time);
    // setInterval(this.handleInterval, 1000);
  };

  handleStateChange = () => {
    const status = this.provider.getPlayerState();
    this.props.dispatch(actions.playerStatus(status));
  };

  renderProviderYoutube() {
    const opts    = {
      width:      '100%',
      playerVars: {
        widget_referrer: document.location.href,
        start:           this.props.video.start,
        showinfo:        0,
        controls:        0,
        autoplay:        1,
        rel:             0
      }
{'fraction_non_alphanumeric': 0.13166703860745368, 'fraction_numerical': 0.008033920999776836, 'mean_word_length': 2.32, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4611765', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1336, 'n_words': 242}