title: get video duration from URL in android app
body: <p>I'm working on an app where the user can see all the video's information and title that are stored on a SERVER. I'm almost done with it except that no matter how I code it, I cannot get the video duration from a given URL.  Lets take this demo video from somewhere on the internet:  <a href="https://12-lvl3-pdl.vimeocdn.com/01/1386/0/6932347/10573836.mp4?expires=1461047937&amp;token=037972137fdfc4c2d9902" rel="nofollow noreferrer">CLICK HERE FOR VIDEO PATH</a>
  I want the app to get the video duration without the need to open the video itself.</p>
  <p>The Code that I'm trying to use on android is this:</p>
  <pre><code>MediaMetadataRetriever retriever = new MediaMetadataRetriever();
      retriever.setDataSource(&quot;https://12-lvl3-pdl.vimeocdn.com/01/1386/0/6932347/10573836.mp4?expires=1461047937&amp;token=037972137fdfc4c2d9902&quot;);
      String time = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
      long timeInmillisec = Long.parseLong( time );
      long duration = timeInmillisec / 1000;
      long hours = duration / 3600;
      long minutes = (duration - hours * 3600) / 60;
      long seconds = duration - (hours * 3600 + minutes * 60);
      Toast.makeText(context,Long.toString(timeInmillisec),Toast.LENGTH_SHORT).show();
  </code></pre>
  <p>But the result that i'm getting is an:  java.lang.IllegalArgumentException
  at line 2 which is &quot;  retriever.setDataSource()   &quot;.
  Can anyone help me find what i'm doing wrong or does android provide another way to get the required information?</p>