This works, it adds autoplay=1 to the URL, causing the video to play.
Appendix: If your video source does not yet have a query string, would it be wise to add ? instead of & , as sometimes happens. This can be done by searching for its existence.
<iframe id="video1" width="520" height="360" src="http://www.youtube.com/embed/TJ2X4dFhAC0?enablejsapi" frameborder="0" allowtransparency="true" allowfullscreen></iframe> <a href="#" id="playvideo">Play video</a> <script> //use .one to ensure this only happens once $("#playvideo").one(function(){ //as noted in addendum, check for querystring exitence var symbol = $("#video1")[0].src.indexOf("?") > -1 ? "&" : "?"; //modify source to autoplay and start video $("#video1")[0].src += symbol + "autoplay=1"; }); </script>
However, most people basically understand that if they want the video to play, they just click on it, and I would advise just leaving it to them or starting the video from auto play.
It should also be noted that autorun does not work on mobile devices (on the Android or iOS platform)
source share