如何彈出一個 jquery 窗口來播放 youtube 視頻?
How to popup a jquery window to play youtube video?(如何彈出一個 jquery 窗口來播放 youtube 視頻?)
本文介紹了如何彈出一個 jquery 窗口來播放 youtube 視頻?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我需要自動播放此視頻.太好了,這段代碼可以播放來自其他來源的視頻,例如 yahoo 等.是否也可以使用 HTML5 而不是 jquery?
解決方案
用于顯示彈出窗口的函數(shù)或插件可能與用于顯示視頻的不同.在這個例子中,我使用了 來自 jQuery Tools 的 Overlay Plugin 來顯示模式然后使用swfobject 以顯示 YouTube Flash Player.或者,您可以使用 HTML5帶有 Flash 后備功能的視頻播放器來顯示視頻,但您仍然需要它來先彈出您的模式.
<a >視頻 1</a><a >視頻 2</a><div class="modal" id="video-modal"><div id="video-container" style="width: 425px; height: 344px;"></div>
<script language="javascript" type="text/javascript">$(函數(shù)(){var videoModal = $('#video-modal').overlay({暴露:{顏色:黑色',加載速度:200,不透明度:0.85},closeOnClick: 真,api: 真的});$('.video-link').click(function() {videoModal.load();var videoUrl = $(this).attr('href');var flashvars = {};變量參數(shù) = {允許全屏:真",允許腳本訪問:總是"};var 屬性 = {};swfobject.embedSWF(videoUrl, 'video-container', '425', '344', '9.0.0', '', flashvars, params, attributes);返回假;});});
I need this video to play automatically. It would be nice, this code can play videos from other sources like yahoo etc.. Is it also possible to use HTML5, instead of jquery?
解決方案
The function or plugin you use to display the popup window will probably be different from what you are using to display the video. In this example I used the Overlay Plugin from jQuery Tools to display the modal then used swfobject to display the YouTube Flash Player. Alternatively, you could use an HTML5 video player with Flash fallback to display the video, but you would still need it to popup your modal first.
<a
class="video-link">Video 1</a>
<a
class="video-link">Video 2</a>
<div class="modal" id="video-modal">
<div id="video-container" style="width: 425px; height: 344px;"></div>
</div>
<script language="javascript" type="text/javascript">
$(function() {
var videoModal = $('#video-modal').overlay({
expose: {
color: 'black',
loadSpeed: 200,
opacity: 0.85
},
closeOnClick: true,
api: true
});
$('.video-link').click(function() {
videoModal.load();
var videoUrl = $(this).attr('href');
var flashvars = {};
var params = {
allowFullScreen: "true",
allowscriptaccess: "always"
};
var attributes = {};
swfobject.embedSWF(videoUrl, 'video-container', '425', '344', '9.0.0', '', flashvars, params, attributes);
return false;
});
});
</script>
這篇關(guān)于如何彈出一個 jquery 窗口來播放 youtube 視頻?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!