<commit_before>import { Component } from 'react'

import { propTypes, defaultProps } from '../props'

const SEEK_ON_PLAY_EXPIRY = 5000

export default class Base extends Component {
  static propTypes = propTypes
  static defaultProps = defaultProps
  isReady = false
  startOnPlay = true
  seekOnPlay = null
  componentDidMount () {
    const { url } = this.props
    this.mounted = true
    if (url) {
      this.load(url)
    }
  }
  componentWillUnmount () {
    this.stop()
    this.mounted = false
  }
  componentWillReceiveProps (nextProps) {
    const { url, playing, volume, muted, playbackRate } = this.props
    // Invoke player methods based on incoming props
    if (url !== nextProps.url && nextProps.url) {
      this.seekOnPlay = null
      this.startOnPlay = true
      this.load(nextProps.url)
    } else if (url && !nextProps.url) {
      this.stop()
      clearTimeout(this.updateTimeout)
    } else if (!playing && nextProps.playing) {
      this.play()
    } else if (playing && !nextProps.playing) {
      this.pause()
    } else if (volume !== nextProps.volume && !nextProps.muted) {
      this.setVolume(nextProps.volume)
    } else if (muted !== nextProps.muted) {
      this.setVolume(nextProps.muted ? 0 : nextProps.volume)
    } else if (playbackRate !== nextProps.playbackRate) {
      this.setPlaybackRate(nextProps.playbackRate)
    }
  }
  shouldComponentUpdate (nextProps) {
    return this.props.url !== nextProps.url
  }
  seekTo (amount) {
    // When seeking before player is ready, store value and seek later
    if (!this.isReady && amount !== 0) {
      this.seekOnPlay = amount
      setTimeout(() => {
        this.seekOnPlay = null
      }, SEEK_ON_PLAY_EXPIRY)
    }
    // Return the seconds to seek to
    if (amount > 0 && amount < 1) {
      // Convert fraction to seconds based on duration
      return this.getDuration() * amount
    }
    return amount
  }
  onPlay = () => {
    const { volume, muted, onStart, onPlay, playbackRate } = this.props
    if (this.startOnPlay) {
      this.setPlaybackRate(playbackRate)
      this.setVolume(muted ? 0 : volume)
      onStart()
      this.startOnPlay = false
    }<commit_msg>Tweak base player update logic<commit_after>import { Component } from 'react'

import { propTypes, defaultProps } from '../props'

const SEEK_ON_PLAY_EXPIRY = 5000

export default class Base extends Component {
  static propTypes = propTypes
  static defaultProps = defaultProps
  isReady = false
  startOnPlay = true
  seekOnPlay = null
  componentDidMount () {
    const { url } = this.props
    this.mounted = true
    if (url) {
      this.load(url)
    }
  }
  componentWillUnmount () {
    this.stop()
    this.mounted = false
  }
  componentWillReceiveProps (nextProps) {
    const { url, playing, volume, muted, playbackRate } = this.props
    // Invoke player methods based on incoming props
    if (url !== nextProps.url && nextProps.url) {
      this.seekOnPlay = null
      this.startOnPlay = true
      this.load(nextProps.url)
    }
    if (url && !nextProps.url) {
      this.stop()
      clearTimeout(this.updateTimeout)
    }
    if (!playing && nextProps.playing) {
      this.play()
    }
    if (playing && !nextProps.playing) {
      this.pause()
    }
    if (volume !== nextProps.volume && !nextProps.muted) {
      this.setVolume(nextProps.volume)
    }
    if (muted !== nextProps.muted) {
      this.setVolume(nextProps.muted ? 0 : nextProps.volume)
    }
    if (playbackRate !== nextProps.playbackRate) {
      this.setPlaybackRate(nextProps.playbackRate)
    }
  }
  shouldComponentUpdate (nextProps) {
    return this.props.url !== nextProps.url
  }
  seekTo (amount) {
    // When seeking before player is ready, store value and seek later
    if (!this.isReady && amount !== 0) {
      this.seekOnPlay = amount
      setTimeout(() => {
        this.seekOnPlay = null
      }, SEEK_ON_PLAY_EXPIRY)
    }
    // Return the seconds to seek to
    if (amount > 0 && amount < 1) {
      // Convert fraction to seconds based on duration
      return this.getDuration() * amount
    }
    return amount
  }
  onPlay = () => {
    const { volume, muted, onStart, onPlay, playbackRate } = this.props
    if (this.startOnPlay) {
      this.setPlaybackRate(playbackRate)
      this.setVolume(muted ? 0 : volume)
      onStart()
      this.startOnPlay = false
    }
{'fraction_non_alphanumeric': 0.11378756595549439, 'fraction_numerical': 0.0041293874741913286, 'mean_word_length': 2.6546521374685668, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '3471436', 'n_tokens_mistral': 1394, 'n_tokens_neox': 1350, 'n_words': 338}