write a program to create cookies in php | debian xfce printer install CUPS | mysqli | vk
 


 

How to Start Youtube Playlist from Random Video



If you want to start a Youtube playlist from random video, just add: &index=random_number to the src attribute of the embed code.

The code

To produce a random number, I use php rand. Something like

	print rand(1,9)

(replace "9" with the count of your playlist videos).

Example

Here is an example of embed code:

<iframe width="853"
		height="480"
		src="//www.youtube.com/embed/videoseries?list=PLSsDdmdvvvGep2WaKOSPQe2jubDvtLblk&index=<?php print rand(1,9)?>"
		frameborder="0"
		allowfullscreen></iframe>

Demo

Refresh the page to see the result.

Εγγραφή!
Sign-up for our free email newsletter. Get updates when new tutorials and tips are published. You can unsubscribe anytime with a click.

Your comments are welcomed!

This site actively encourages commenting on any post. Comments are not pre-moderated, but this community does not tolerate direct or indirect attacks, name-calling or insults. Please, read terms of use and Comment Policy at privacy policy.

More tips