I am using youtube video in "iframe" with height width src etc. but it is playing auto. I want to play it with onclick. Please help me.
Asked
Active
Viewed 5.8k times
13
-
Is your IFrame pointing to the video on YouTube.com? e.g. – Alex W Jun 03 '12 at 04:55
-
yes it is showing the same path – ManpreetSandhu Jun 05 '12 at 04:01
-
I posted the alternative to the `iframe` way to do it. You just use `object` and `embed` tags. – Alex W Jun 05 '12 at 21:09
-
Add a transparent div on top of the YouTube video with CSS: https://stackoverflow.com/a/32601686/4455570 – Gabriel Wamunyu Nov 22 '19 at 21:59
7 Answers
15
To disable autoplay, just put &autoplay=0 after the video ID so it looks like this:
<object width="425" height="350">
<param name="movie" value="http://www.youtube.com/v/OdT9z-JjtJk&autoplay=0"></param>
<embed src="http://www.youtube.com/v/OdT9z-JjtJk&autoplay=0" type="application/x-shockwave-flash" width="425" height="350"></embed>
</object>
http://support.google.com/youtube/bin/answer.py?hl=en&answer=1181821
Updated code.

Jayden Lawson
- 2,154
- 2
- 21
- 24

Alex W
- 37,233
- 13
- 109
- 109
3
It used to work. YouTube only verifies how to autoplay but they dont talk aboth NOT autoplay.
&autoplay=0 does not work.
http://support.google.com/youtube/bin/answer.py?hl=en&answer=171780&rd=1

Al Guevara
- 41
- 1
1
Jut put the "#t=XmXs" after the URL. NOTICE that you have to change the X to a certain time, such as 2m30s.

Daniel Neves
- 147
- 1
- 4
0
Remove autoplay=1 allow='autoplay'
and play video by click on link.
<a id="play-video" href="#">Play Video</a><br />
<iframe id="video" src="//www.youtube.com/embed/9B7te184ZpQ?rel=0" frameborder="0"></iframe>
$(document).ready(function() {
$('#play-video').on('click', function(ev) {
$("#video")[0].src += "&autoplay=1";
ev.preventDefault();
});
});

Shameem Ali
- 181
- 2
- 7
-1
With a code like this:
<iframe width="680" height="382" frameborder="0" src="//www.youtube.com/embed/n4K1Qpj1Ljg?list=UU3qGUTKOSIKbp08itEn8VIA?autoplay=0">
</iframe>

Shire
- 398
- 2
- 9
-2
Instead of using &autoplay=false
, try using ?autoplay=false
regardless of whether there is a preceding ?rel=n
.
This seems to be working for me after getting it by trial and error.

Ram
- 3,092
- 10
- 40
- 56