<commit_before>import React, { Component, PropTypes, createElement } from 'react'
import vendorPropTypes from './vendor-prop-types'

class HTML5 extends Component {
  static propTypes = {
    ...vendorPropTypes,
    useAudioObject: PropTypes.bool
  }

  componentWillMount() {
    if (this.props.vendor === 'audio') {
      this._bindAudioPlayerEvents(true)
    }
  }

  componentWillReceiveProps(nextProps) {
    if (this.props.src !== nextProps.src) {
      this.stop()
      this._bindAudioPlayerEvents(true, nextProps)

      // allow the new media to load and then play
      setTimeout(() => {
        this.play()
      })
    }
  }

  componentDidUpdate(lastProps) {
    if (lastProps.vendor === 'audio' && this.props.vendor === 'video' && this.props.autoPlay) {
      this.play()
    }
    if (lastProps.vendor === 'video' && this.props.vendor === 'audio') {
      this._bindAudioPlayerEvents(true)
    }
  }

  componentWillUnmount() {
    if (this.props.vendor === 'audio') {
      this.stop()
      this._bindAudioPlayerEvents(false)
    }
  }

  get instance() {
    return this._player
  }

  play() {<commit_msg>make sure audio and video stop on unmount<commit_after>import React, { Component, PropTypes, createElement } from 'react'
import vendorPropTypes from './vendor-prop-types'

class HTML5 extends Component {
  static propTypes = {
    ...vendorPropTypes,
    useAudioObject: PropTypes.bool
  }

  componentWillMount() {
    if (this.props.vendor === 'audio') {
      this._bindAudioPlayerEvents(true)
    }
  }

  componentWillReceiveProps(nextProps) {
    if (this.props.src !== nextProps.src) {
      this.stop()
      this._bindAudioPlayerEvents(true, nextProps)

      // allow the new media to load and then play
      setTimeout(() => {
        this.play()
      })
    }
  }

  componentDidUpdate(lastProps) {
    if (lastProps.vendor === 'audio' && this.props.vendor === 'video' && this.props.autoPlay) {
      this.play()
    }
    if (lastProps.vendor === 'video' && this.props.vendor === 'audio') {
      this._bindAudioPlayerEvents(true)
    }
  }

  componentWillUnmount() {
    this.stop()

    if (this.props.vendor === 'audio') {
      this._bindAudioPlayerEvents(false)
    }
  }

  get instance() {
    return this._player
  }

  play() {
{'fraction_non_alphanumeric': 0.13953488372093023, 'fraction_numerical': 0.0008775778850372971, 'mean_word_length': 2.8063439065108513, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1838510', 'n_tokens_mistral': 712, 'n_tokens_neox': 700, 'n_words': 143}