我有以下内容,它会显示图片,当用户点击图片时,会将他们带到Youtube视频:
<html>
<head>
<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("jquery", "1", {uncompressed: true});
</script>
<script>
jQuery(function($){
$('a').click(function() {
$(this).html('<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/Msef24JErmU&hl=en_US&fs=1&rel=0&color1=0x2b405b&color2=0x6b8ab6"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Msef24JErmU&hl=en_US&fs=1&rel=0&color1=0x2b405b&color2=0x6b8ab6" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>');
return false;
});
});
</script>
</head>
<body>
<a href="javascript:void();"><img src="http://www.clipov.net/pic/paul_oakenfold+%5Bstarry_eyed_surprise%5D+_+3-07+mtv_dance_beats+clear.jpg"></a>
</body>
</html>
问:如何自动播放视频以防止用户点击(第二次)?
答案 0 :(得分:1)
只需将autoplay = 1添加到您的embed src属性:
http://www.google.com/support/youtube/bin/answer.py?hl=en&answer=56107
答案 1 :(得分:1)
http://www.google.com/support/youtube/bin/answer.py?hl=en&answer=56107
是的,你可以自动播放电影!在视频观看页面的“关于此视频”部分,我们为您提供了嵌入视频的源代码:
<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/OdT9z-JjtJk"></param><embed src="http://www.youtube.com/v/OdT9z-JjtJk" type="application/x-shockwave-flash" width="425" height="350"></embed></object>
要使其自动播放,只需在视频ID后附加“&amp; autoplay = 1”即可,如下所示:
<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/OdT9z-JjtJk&autoplay=1"></param><embed src="http://www.youtube.com/v/OdT9z-JjtJk&autoplay=1" type="application/x-shockwave-flash" width="425" height="350"></embed></object>