2012-02-16 144 views
1

我使用Fancybox作爲燈箱。我在外部HTML文檔中設置了視頻,並在鏈接從主文檔中單擊時加載到Fancybox中。問題是Fancybox在某種程度上阻止了Chrome中的「自動播放」。 Firefox似乎工作正常。Fancybox Chrome自動播放視頻問題

From index.html 

Fancybox script: 
<script type="text/javascript"> 
$(document).ready(function() { 
$(".video").fancybox({ 
'overlayOpacity': 0.9, 
'hideOnContentClick': true 
}); 
}); //ready 
</script> 

Body code: 
<li><a class="video" href="video/healthcarevideo1.html">Smart Outsourcing (HIPPA 5010, EMR)</a></li> 
<li><a class="video" href="video/healthcarevideo2.html">Guaranteed Rejection of Claims (HIPPA 5010)</a></li> 

-->From healthcarevideo1.html: 
<video width="640" height="360" controls autoplay> 
<source src="http://clips.vorwaerts-gmbh.de/VfE_html5.mp4" type="video/mp4"> 
<source src="http://clips.vorwaerts-gmbh.de/VfE.ogv" type="video/ogg"></video> 

關於這個問題可能存在的任何想法? 謝謝!

EDIT: JFK, below, is correct. Final code:  
<script type="text/javascript"> 
$(document).ready(function() { 
$(".video").fancybox({ 
'overlayOpacity': 0.9, 
'width': 640, //or whatever 
'height': 360, //or whatever 
'type' : 'iframe', 
'scrolling': 'no' 
}); 
}); //ready 
</script> 

感謝大家的幫助。

+1

你能證明你的healthcarevideo HTML文件的內容?你有沒有嘗試在自定義fancybox腳本中設置''type':'iframe'? (你可能需要設置'width'和'height') – JFK 2012-02-16 20:53:09

+0

我添加了上面的視頻代碼。 Fancybox加載,顯示電影,電影只是不玩。 Firefox一切正常。我可以將視頻html拖動到瀏覽器,並在Chrome中播放。這就是爲什麼我認爲它可能是Fancybox。 – Andrea 2012-02-16 20:58:30

+0

當您不使用Fancybox時,Chrome會自動播放嗎? – Kevin 2012-02-16 21:06:47

回答

0

您是否嘗試在您的自定義fancybox腳本中設置'type':'iframe'? (您可能需要設置widthheight太),如:

$(".video").fancybox({ 
'type': 'iframe', 
'width': 660, 
'height': 380, 
'scrolling': 'no', 
'overlayOpacity': 0.9 
});