Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-12-2013, 10:18 AM   PM User | #1
vibleer
New to the CF scene

 
Join Date: Jan 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
vibleer is an unknown quantity at this point
Youtube autoplay

Hello i have this javascript that randomly plays youtube clips but i have been looking for what to add so the videos can autoplay, can anyone please help me? tried adding &autoplay=1 at the end of video urls but wont work



<script type="text/javascript">

function rand ( n )
{
return ( Math.floor ( Math.random ( ) * n + 1 ) );
}

// Store youtube [CHANGES NEEDED IN THE 3 URLS BELOW]
var vids = new Array ( );
vids[1] = "http://www.youtube.com/embed/WdO85Qf4Poc";
vids[2] = "http://www.youtube.com/embed/4y6CCSCQAmw";
vids[3] = "http://www.youtube.com/embed/Yp6KZyNEkcU";

// Pick a random video from the list
function pick_vid ( )
{
var numberOfImages = 3; //[CHANGE THE 3 TO THE TOTAL NUMBER OF VIDS YOU USE]
var num = rand(numberOfImages)-1;

document.getElementById("random_youtube_vid").src = vids[num];
}
</script>
vibleer is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:48 AM.


Advertisement
Log in to turn off these ads.