title: How to fix "Uncaught TypeError: Failed to set the 'currentTime' property on 'HTMLMediaElement'
body: <p>I am working with Cuepoint.js to create text links that cue HTML5 video to a time marker corresponding with particular lines of text. I need to dynamically assign the links a time value already written to an array as a string. I know I need to use parseInt() to recast the values as integers when they are retrieved from the array. Since the links and their times are dynamic, I also need to assign the links their times within a for loop where they are then pushed to another array. Here's the code</p>
  
  <pre><code>    var cueTimes = [];
      for (var j = 0; j &lt; textItems.length; j++) {
          var times = parseInt(timeItems[j]);
          cueTimes.push(times);
          $(".field-name-field-text-"+(j+1)+" &gt; div &gt; div").click(function(){ cuepoint.setTime(cueTimes[j])});
      console.log(cueTimes[j]);
      }
  </code></pre>
  
  <p>When I run the code, however, I receive this error. </p>
  
  <p><strong><em>Uncaught TypeError: Failed to set the 'currentTime' property on 'HTMLMediaElement': The provided double value is non-finite.</em></strong></p>
  
  <p>As far as I can tell, the integer isn't being correctly read as such by jQuery. However, when I output the time values to my console, they appear as integers. When I test the code using a static array index  (for example setting cueTimes[0]), the code runs and works as expected. </p>
  
  <p>Any suggestions on how to fix/work around this greatly appreciated.</p>
  
  <p>Thanks!</p>
  
  <p>Here is the line from the Cuepoint.jS file that prompts the error:</p>
  
  <pre><code>Cuepoint.prototype.setTime = function(time) {
          this.time = time;
          this.video.currentTime = time;
          return this.video.play();
      };
  </code></pre>
  
  <p>Cuepoint.js code:</p>
  
  <pre><code>(function() {
  /* Cuepoint Coffee. A simple library for HTML5 Video Subtitles and Cuepoints */
  
  /**
   * @class Utils 
  */
  
  var Cuepoint, Utils, utils;
  Utils = (function() {
      function Utils() {}
      Utils.prototype.log = function(args) {
          this.args = args;
          if (window.console) {
              return console.log(Array.prototype.slice.call(this, arguments));
          }
      };
      return Utils;
  })();
  
  /**
   * @class Cuepoint
   */
  
  Cuepoint = (function() {
      function Cuepoint() {
          this.nativeKeys = Object.keys;
      }
      Cuepoint.prototype.init = function(slides) {
          var key, value, _results;
          this.slides = slides;
          this.subtitles = document.getElementById("subtitles");
          this.video = document.getElementById("video");
          _results = [];
          for (key in slides) {
              value = slides[key];
              this.addSlide(key, value);
              _results.push(this.events.call);
          }
          return _results;
      };
      Cuepoint.prototype.events = function() {};
      Cuepoint.prototype.currentTime = function() {
          return this.video.currentTime;
      };
      Cuepoint.prototype.update = function(html) {
          this.html = html;
          return this.subtitles.innerHTML = this.html;
      };
      Cuepoint.prototype.setTime = function(time) {
          this.time = time;
          this.video.currentTime = time;
          return this.video.play();
      };
      Cuepoint.prototype.addSlide = function(time, html) {
          var self;
          this.time = time;
          this.html = html;
          self = this;
          return this.video.addEventListener("timeupdate", function() {
              if (this.currentTime &gt;= time &amp;&amp; this.currentTime &lt;= time + 0.3) {
                  return self.update(html);
              }
          },
          false);
      };
      Cuepoint.prototype.play = function() {
          return this.video.play();
      };
      Cuepoint.prototype.pause = function() {
          if (!this.video.paused) {
              return this.video.pause();
          }
      };
      return Cuepoint;
  })();
  utils = new Utils;
  window.cuepoint = new Cuepoint;
  </code></pre>
  
  <p>}).call(this);</p>