Loop to another video after so many seconds

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mecha_godzilla
Forum Contributor
Posts: 375
Joined: Wed Apr 14, 2010 4:45 pm
Location: UK

Re: Loop to another video after so many seconds

Post by mecha_godzilla »

You can either do this using JavaScript or PHP. Do you have any controls in your pop-up window that need to remain onscreen? If so, you might want to consider loading your video 'page' into an iframe.

To display a new page using PHP, you'd just need to use something like the sleep() function and a redirection - something like:

Code: Select all

$redirected_address = 'Location: http://www.mysite.com/show_video.php?video_id=' . $next_video;
header ($redirected_address);
exit();
Thinking about it, JavaScript would probably work better because you're not tying up your PHP script. If you want to use JavaScript you just need to write a timer script which then calls window.location(). When you display the next video, is there any order to them or is it random? If you need to send the value of the next video you could use PHP to dynamically write the value of video in your JavaScript function; you'd then just need to call the function using the onLoad="" attribute in the <body> tag of your page.

HTH,

Mecha Godzilla
Post Reply