所以基本上,我有一个弹出的代码,使分区弹出。里面有一个YouTube视频播放器。一切正常,直到我关上窗户,我仍然可以在背景中听到音乐,这意味着视频仍在播放。我想阻止它。 我做了一些研究,并落在YouTube的API上,但它仍然无法正常工作。弹出窗口中的Youtube视频不会停止播放当窗口关闭
这里是我的股利
echo "<div id='popupContact'>";
echo "<a id='popupContactClose'>x</a>";
echo "<div><h1>" .$row['title']. "</h1></div>";
echo "<p id='contactArea'>";
if($row[type] == "image")
echo "<img src='gallery/" .$row['path']. "' alt='" .$row['title']. "'/>";
else
echo "<iframe width='560' height='315' src='http://www.youtube.com/v/" .$row['path']."? enablejsapi=1&version=3&playerapiid=ytplayer' frameborder='0' allowfullscreen></iframe>";
echo "<br/><br/>" .$row['description']. "</p>";
echo "</div>";
echo "<div id='backgroundPopup'></div>";
代码和这里是弹出代码:
//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
//LOADING POPUP
//Click the button event!
$("#button").click(function(){
//centering with css
centerPopup();
//load popup
loadPopup();
});
//CLOSING POPUP
//Click the x event!
$("#popupContactClose").click(function(){
disablePopup();
});
//Click out event!
$("#backgroundPopup").click(function(){
disablePopup();
});
//Press Escape event!
$(document).keypress(function(e){
if(e.keyCode==27 && popupStatus==1){
disablePopup();
}
});
});
//disabling popup with jQuery magic!
function disablePopup(){
//disables popup only if it is enabled
if(popupStatus==1){
$("#backgroundPopup").fadeOut("slow");
$("#popupContact").fadeOut("slow");
popupStatus = 0;
stop();
}
}
function onYouTubePlayerReady(playerId) {
alert("YAY");
ytplayer = document.getElementById("ytplayer");
}
function stop() {
if (ytplayer) {
ytplayer.stopVideo();
}
}
谢谢 阿糖胞苷
我没有看到代码的函数'loadPopup()'当点击#键时调用.. – jmm 2012-08-15 21:22:14
功能loadPopup(){ \t //只加载弹出,如果它被禁用 \t如果( 。popupStatus == 0){ \t \t $( “#backgroundPopup”)的CSS({ \t \t \t “不透明性”: “0.7” \t \t}); \t \t $(“#backgroundPopup”)。fadeIn(“slow”); (“#popupContact”)。fadeIn(“slow”); \t \t popupStatus = 1; \t} } – user1049769 2012-08-16 00:33:32
您是否查看了我在以下答案中列出的文档? – jmm 2012-08-16 01:42:15