Web Video Tips: Making You Tube play automatically

bigrock wrote on 2/9/2010, 10:29 PM
One of the things that would be nice to have if embedding video in a webpage is the ability to force YouTube to play automatically when someone visits the page. And that is something you can do that is not on selectable switch on YouTube.

This is how it is done. I am assume you have uploaded the video to YouTube already. So go ahead and play the video on YouTube. Down the right hand side of the player just below the url display is a place where you can get the code to embed the file in a webpage. There are a number of selectable options. I do recommend turning off the related videos switch or you will have someone else's videos being played after yours. So copy that embed code to your webpage where you want to display the player. I have setup a sample page at Autoplay Sample

The embed code for this player as provide by YouTube was:

<object width="873" height="525"><param name="movie" value="http://www.youtube.com/v/LWh2xPVMYfo&hl=en_US&fs=1&rel=0&color1=0x2b405b&color2=0x6b8ab6&hd=1&border=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/LWh2xPVMYfo&hl=en_US&fs=1&rel=0&color1=0x2b405b&color2=0x6b8ab6&hd=1&border=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="873" height="525"></embed></object>

To this code we will add one additional parameter and that is &autoplay=1. Look in code sample to see where you need to insert that parameter to get it the player to autostart:

<object width="873" height="525"><param name="movie" value="http://www.youtube.com/v/LWh2xPVMYfo&hl=en_US&fs=1&rel=0&color1=0x2b405b&color2=0x6b8ab6&hd=1&border=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/LWh2xPVMYfo&hl=en_US&fs=1&rel=0&autoplay=1&color1=0x2b405b&color2=0x6b8ab6&hd=1&border=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="873" height="525"></embed></object>


Using this parameter it becomes a bit of a cheap way to do push streaming as we can force autoplay of the file without incurring a bandwidth cost. One does have to put up with any YouTube issues but they certainly have come a long way to improving there service to the point this is quite a usable option.

Comments

bigrock wrote on 2/9/2010, 10:31 PM
One of the other things you might want to do is force the video to loop.

Also doable, here's how:

For the previous post we added the &autoplay=1 so to also loop we are going to expand this to say &autoplay=1&loop=1 and insert into exactly the same place in the embedded code.

Now the file will keep playing for the browser's cache until you shut it off or asteriod hits the planet and wipes us all out.

Here is a sample of that in action: Autoloop Autoplay Sample.
bigrock wrote on 2/9/2010, 10:34 PM
To complete this step of tips you can also use the autoplay parameter with the Youtube URL.

So for this same video in the previous two posts the URL is for a Regular Player

If add the autoplay parameter that will make the URL for a Regular Player with AutoStart

Note: I purposedly left the forum's link command out on these two urls so they would not autostart as you read this thread. Just copy and paste them into a browser yourself to try them.

You could also try adding the loop parameter but I think you will find out unless you are using an embedded player as in the first two examples it will usually be ignored.
Chienworks wrote on 2/9/2010, 10:42 PM
Autoplay seems pretty rude to me. I don't like it when media starts playing just from me visiting a page. I'd rather be given the option to start it *IF* i choose to. Often when media starts autoplaying i leave the page rarely to visit again.
bigrock wrote on 2/10/2010, 12:33 AM
The case of rudeness or not is irrelevant. This is a technical discussion of how to do it, not whether you should. And there some situations where push media is appropriate and expected.
Chienworks wrote on 2/10/2010, 3:15 AM
I understand it's a technical discussion. I do however think considering rudeness is very relevant. If you were giving tips on the best ways to hide whoopie cushions on people's chairs you might have a very valid technical description of the best methods. I would still point out that your method, while technically correct, has the potential to make you very unpopular.

As media producers we have a responsibility to our audience, and not just to the producer. Many folks consider automatic pushes unwelcome. I can see that if you have a menu of videos to watch and a user selects one then having it start automatically can be a good thing. However, having a video start simply because one has entered a website is presumptuous of the viewer's resources, time, and desires.
DGates wrote on 2/10/2010, 3:28 AM
Yeah BR, chill out.

Most people are annoyed by auto-play.
Jay Gladwell wrote on 2/10/2010, 4:04 AM

Agreed, I am totally against autoplay. What really fries my shorts is a website with audio that starts playing and there's no way to turn off the sound.

If you have links to videos that start playing as soon as they are selected--viewers' choice--that's altogether different.

At any rate, "force" me to watch a video or listen to audio and I'll leave your site quicker that you can say "click on it."


bigrock wrote on 2/10/2010, 8:11 AM
What we seem to forget is this, push media is very common. It does not have to be the central focus of the page. Push media is used by advertising (you know that thing pays for virtually all web activity) in a big way. It can be a little thing in the corner, it doesn't have to be the main window, and most of the time you are unaware it is this there.

It is up to any indiviual web developer to decide whether it is appropriate or not to their intent. But this was a technical discussion on some options with YouTube, nothing more.
BudWzr wrote on 2/10/2010, 9:33 AM
So your point is that YouTube videos can be controlled with standard Macromedia player parameters?

Yes, that IS something handy to know.

And you can even skip the YouTube JS and just embed the media in your own player with your own JS and it won't have all that overlay stuff that YT puts on it.