title: jwplayer - how do I get video duration before playback?
body: <p>I'm trying to get the duration of a video before the jwplayer starts playing. I tried calling getDuration () in the onReady event callback, but it returns -1. When I call getDuration () in the onPlay event callback, I get the correct value. Any ideas?</p>
  
  <p>Here's my code:</p>
  
  <pre><code>&lt;video src="movie.mp4" id="video" width="800" height="600"&gt;&lt;/video&gt;
  &lt;script type="text/javascript"&gt;
  jwplayer ('video').setup ({
      flashplayer: '/js/mediaplayer-5.10/player.swf',
      width: 600,
      height: 400,
      events: {
          onReady: function () {
              var duration = this.getDuration();
              alert ('ready, duration: ' + duration);
          },
          onPlay: function (state) {
              alert ('play, duration: ' + this.getDuration());
          }
      }
  });
  &lt;/script&gt;
  </code></pre>