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:
$ytvidid = 'qasCLgrauAg';
$ytdataurl = "http://gdata.youtube.com/feeds/api/videos/". $ytvidid;
$feedURL = $ytdataurl;
$sxml = simplexml_load_file($feedURL);
$media = $sxml->children('http://search.yahoo.com/mrss/');
// get <yt:duration> node for video length
$yt = $media->children('http://gdata.youtube.com/schemas/2007');
$attrs = $yt->duration->attributes();
$length = $attrs['seconds'];
that returns in this example 16 seconds, so i've tried:
usleep($length * 1000000);
flush();
loadnext();
function loadnext(){
//heres my next video
}
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 :)