title: How do you get the duration of a video captured via PhoneGap?
body: <p>I need to know the duration of a video captured via PhoneGap before uploading to the server. The documentation for the <a href="http://docs.phonegap.com/en/2.0.0/cordova_media_capture_capture.md.html#MediaFile.getFormatData" rel="nofollow">MediaFile.getFormatData</a> is a little vague and doesn't seem to be working.</p>
  
  <p>I have been able to successfully capture and upload a video, so all of that is working, just the duration part isn't.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Running on an iPhone 4 with iOS 5.1.1</p>
  
  <pre><code>navigator.device.capture.captureVideo(function(mediaFile) {
          if(mediaFiles.length == 1) {
              $('#video_url').val(mediaFiles[0]);
              var profileVideo = document.getElementById('profile-video');
              profileVideo.src = mediaFiles[0].fullPath;
  
              var formatData;
              mediaFiles[0].getFormatData(function(data) {
                  formatData = data;
              });
  
              if(formatData.duration &gt; 30) {
                  $('#infoMessage').html("Your video is longer than the allowed 30 seconds. Please record a new video. You can trim your video after it's been recorded.")
              }
          }
      }, function(error) {
      }, null);
  </code></pre>