title: Android MediaPlayer: getDuration() returns 0 after prepare()
body: <p>I'm using MediaPlayer on Honeycomb and cannot get the duration of any HLS (http live streaming) video in the function onPrepared(). </p>
  
  <p>If <code>getDuration()</code> is called after <code>prepare()</code>, it returns 0:</p>
  
  <pre><code>public void onPrepared(MediaPlayer mp) {
      // getduration returns 0
      mediaPlayer.start();
      Log.d(TAG, "duration: " + mediaPlayer.getDuration());
  }
  </code></pre>
  
  <p>However, the videos starts playing.</p>
  
  <p>If <code>getDuration()</code> is called in <code>onVideoSizeChanged()</code> it returns the correct value,</p>
  
  <pre><code>public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
      // returns the correct value
      Log.d(TAG, "duration: " + mediaPlayer.getDuration());
  }
  </code></pre>
  
  <p>Why does <code>getDuration()</code> work in <code>onVideoSizeChanged()</code> but not in <code>onPrepared()</code>?</p>
  
  <p><strong>Edit</strong>: At first I thought getDuration() doesn't work at all, but found it to return the correct value in onVideoSizeChanged(). Modified question to reflect this.</p>