Random youtube Video from list

  • 1 Replies
  • 6008 Views

0 Members and 1 Guest are viewing this topic.

*

Offline rmoore

  • Super Guru
  • ***
  • 20
  • 4
Random youtube Video from list
« on: November 24, 2009, 04:20:21 PM »


Show 7 different 10 minute videos randomly on the sign throughout the lunch and dinner period asking people to vote for May Court.  I know, not exactly saving the world, but pretty important to the folks on my campus.  I had all the videos as m4p's and decided to use YouTube as my source.  Heck, a little extra SEO doesn't hurt anyone right.  I could also use them in other places on our sites, which is another major bonus.  Samsung allows you to show a web page as an area of a screen.  I designed some custom graphics for the screen and left an area for an embedded YouTube player.  I then worked from an image randomizer javascript and added the autoplay querystring variable to the youtube link.  This worked.  You can see what it looks like in its naked form http://intranet.brenau.edu/magicnet/video/mayCourt_2010/.  If you refresh, you'll see the random videos.  I used this on the signs which works great, but I also used it on out Intranet (on the right, May Court News - I use Dot Net Nuke).  The biggest trick was setting the sign refresh to 20 seconds as MagicInfo won't schedule less than 1 minute at a time.  So people get 3 announcements in 1 minute before the screen changes.  Next time we'll make the video at least 1 minute.

So for everyone looking for a YouTube randomizer here you go:

Put this in the <Head>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
// Set up the image files to be used.
var theImages = new Array() // do not change this
// To add more image files, continue with the
// pattern below, adding to the array.

theImages[0] = 'http://www.youtube.com/v/oVMujuGpVZc&hl=en_US&fs=1&rel=0&autoplay=1'
theImages[1] = 'http://www.youtube.com/v/jWtWPtKWgfQ&hl=en_US&fs=1&rel=0&autoplay=1'
theImages[2] = 'http://www.youtube.com/v/DFI85wSjBBE&hl=en_US&fs=1&rel=0&autoplay=1'
theImages[3] = 'http://www.youtube.com/v/U4xSkjFVO6E&hl=en_US&fs=1&rel=0&autoplay=1'
theImages[4] = 'http://www.youtube.com/v/AxLRmf1xQso&hl=en_US&fs=1&rel=0&autoplay=1'
theImages[5] = 'http://www.youtube.com/v/Slm8X1rrQW0&hl=en_US&fs=1&rel=0&autoplay=1'
theImages[6] = 'http://www.youtube.com/v/ga-7b9xRT1Y&hl=en_US&fs=1&rel=0&autoplay=1'


// do not edit anything below this line

var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer = new Image()
preBuffer.src = theImages
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('');
}

// End -->
</script>

Put this in the <Body>

<SCRIPT LANGUAGE="JavaScript">


<!-- Begin
showImage();
// End -->
</script>

Enjoy:)

-Ron

*

Offline fluidium

  • Moderator
  • SuperHero & MegaGuru
  • *****
  • 116
  • 26
Re: Random youtube Video from list
« Reply #1 on: November 24, 2009, 09:07:10 PM »
Nice one Ron-if you place this in the head of the page it should fix your 20 second problem  ;D

<meta http-equiv="refresh" content="20">