<commit_before>import React from 'react';
import { as } from '../utils/syno-api'
import '../styles/Player.global.css'

class Player extends React.Component {
  constructor(props) {
    super(props)

    this.handlePlayPauseClick = this.handlePlayPauseClick.bind(this)

    const songs = null
    const playSongIdx = null
    const songUrl = ''
    const playing = false
    this.state = {songs, playSongIdx, songUrl, playing}
  }

  componentDidMount() {
    
  }

  componentDidUpdate(prevProps, prevState) {
    if (this.props.songIdx && this.props.songs[this.props.songIdx]) {
      const songUrl = as.getStreamSongUrl(this.props.profile, this.props.songs[this.props.songIdx].id)
      // const songUrl = 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/557257/wwy.mp3'
      if (this.state.songUrl != songUrl) {
        console.log(songUrl)
        this.setState({songUrl})
      }
    }
  }

  handlePlayPauseClick() {
    let audio = document.getElementById('audio')
    if (this.state.playing) {
      audio.pause()
      this.setState({playing: false})
    } else {
      audio.play()
      this.setState({playing: true})
    }
    // console.log(audio.currentSrc, audio.currentTime, audio.duration)
  }

  render() {
    return (
      <div className="player">
        <button onClick={this.handlePlayPauseClick} type="button">Play</button>
        { (this.props.songIdx || this.props.songIdx === 0) &&
        <audio id="audio" src={this.state.songUrl} ></audio>
        }
        { (this.props.songIdx || this.props.songIdx === 0) &&
        <p><small>{this.props.songs[this.props.songIdx].title}</small></p>
        }
      </div>
    )
  }
}

export default Player<commit_msg>add debug info to Player component<commit_after>import React from 'react';
import { as } from '../utils/syno-api'
import '../styles/Player.global.css'

class Player extends React.Component {
  constructor(props) {
    super(props)

    this.handlePlayPauseClick = this.handlePlayPauseClick.bind(this)

    const songUrl = ''
    const playing = false
    this.state = {songUrl, playing}
  }

  componentDidMount() {
    
  }

  componentDidUpdate(prevProps, prevState) {
    if (this.props.songIdx && this.props.songs[this.props.songIdx]) {
      const songUrl = as.getStreamSongUrl(this.props.profile, this.props.songs[this.props.songIdx].id)
      // const songUrl = 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/557257/wwy.mp3'
      if (this.state.songUrl != songUrl) {
        console.log(songUrl)
        this.setState({songUrl})
      }
    }
  }

  handlePlayPauseClick() {
    let audio = document.getElementById('audio')
    if (this.state.playing) {
      audio.pause()
      this.setState({playing: false})
    } else {
      audio.play()
      this.setState({playing: true})
    }
    // console.log(audio.currentSrc, audio.currentTime, audio.duration)
  }

  render() {
    return (
      <div className="player">
        <span onClick={this.handlePlayPauseClick} type="button">Play</span>
        <p>{this.props.player.songs.length} loaded ({this.props.player.currentPlaylistId}) - Song {this.props.player.currentSongIdx} - Status {this.props.player.status}</p>
        { (this.props.player.currentSongIdx || this.props.player.currentSongIdx === 0) &&
        <audio id="audio" src={this.state.songUrl} ></audio>
        }
        { (this.props.player.currentSongIdx || this.props.player.currentSongIdx === 0) &&
        <p><small>{this.props.player.songs[this.props.player.currentSongIdx].title}</small></p>
        }
      </div>
    )
  }
}

export default Player
{'fraction_non_alphanumeric': 0.15306980656013458, 'fraction_numerical': 0.006167647883375385, 'mean_word_length': 2.8572972972972974, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3591466', 'n_tokens_mistral': 1211, 'n_tokens_neox': 1158, 'n_words': 183}