title: php set timer then call a function
body: <p>i have a youtube video which I get its duration in seconds, I want to set a timer for that video and once it's done then call a function which has a different video.  So far what i have is this:</p>
  
  <pre><code>$ytvidid = 'qasCLgrauAg';
  $ytdataurl = "http://gdata.youtube.com/feeds/api/videos/". $ytvidid;
  $feedURL = $ytdataurl;
  $sxml = simplexml_load_file($feedURL);
  $media = $sxml-&gt;children('http://search.yahoo.com/mrss/');
  // get &lt;yt:duration&gt; node for video length
  $yt = $media-&gt;children('http://gdata.youtube.com/schemas/2007');
  $attrs = $yt-&gt;duration-&gt;attributes();
  $length = $attrs['seconds'];
  </code></pre>
  
  <p>that returns in this example 16 seconds, so i've tried:</p>
  
  <pre><code>usleep($length * 1000000);
  flush();
  loadnext();
  
  function loadnext(){
      //heres my next video
  }
  </code></pre>
  
  <p>for some reason this doesn't work..am i doing something wrong? I've also tried javascript window.setInterval(...) but that doesn't work either in reseting the interval when the next video loads.  Any help is much appreciated :)</p>