title: Youtube video api in JavaScript
body: <p>I have used the YouTube video API in JavaScript </p>
  
  <p>And play pause and stop events I have used </p>
  
  <p>Now I got total current time which total watched time, 
  but my main problem is this:</p>
  
  <p>Watch a video for a few seconds and fast forward, then watch another few seconds and see what time it records.... If I watch a video for 5 seconds, then fast forward to minute 10 and watch another 5 seconds, the time I actually watched the video is 10 seconds, not 10 minutes.</p>
  
  <p>Here is my code : </p>
  
  <pre><code>function onytplayerStateChange(event) 
  { 
      //alert("Status=&gt;"+event.data); 
      if(event. data == 1) { 
          if(Math.floor(event.target.A.currentTime) == 0) { 
              previous_track_time = current_track_time = 0; 
              total_track_time = event.target.A.duration; 
          } else { 
              previous_track_time = current_track_time; 
              current_track_time = event.target.A.currentTime; 
          } 
      } 
      if(event.data == 2) 
      { 
          current_track_time = event.target.A.currentTime; 
          total_track_time =(event.target.A.duration-(current_track_time-previous_track_time)); 
          previous_track_time = current_track_time; 
      }
  } 
  </code></pre>
  
  <p>Can you fix that please?</p>