import React from 'react'
import youTubePlayer from 'youtube-player' 

class VideoPlayer extends React.Component {

  constructor (props) {
    super(props)
    
    this.internalPlayer = null
  }
  
  componentDidMount() {
    this.createPlayer()
  }

  updateComment () {
    this.props.updateComment(this.currentTime)
  }

  onPlayerStateChange = (event) => {
    console.log(event)
    if(event.target.getPlayerState() === 1) {
      this.interval = setInterval(() => {
        this.currentTime = event.target.getCurrentTime()
        console.log(this)
        this.updateComment()
      }, 100)
    }
    else if (event.target.getPlayerState() === 2) {
      clearInterval(this.interval)
    }
  }

  createPlayer() {
    this.internalPlayer = youTubePlayer(this.props.container, {
      videoId: this.props.videoId,
    })
    this.internalPlayer.on('stateChange', this.onPlayerStateChange)
  }

  

  render () {
    return (
      <span>
        <div id={this.props.container}>
        </div>  
      </span>
    )
  }
}

export default VideoPlayer

@@ -360,31 +360,8 @@
 %3E %7B%0A
-    console.log(event)%0A
     
@@ -505,34 +505,8 @@
 e()%0A
-        console.log(this)%0A
     

remove consolelogs