つまり、基本的に、divをポップアップさせるポップアップコードがあります。その中には、YouTubeのビデオプレーヤーがあります。ウィンドウを閉じるまで、すべてが機能します。バックグラウンドで音楽を聞くことができます。つまり、ビデオはまだ再生中です。やめたい。私はいくつかの調査を行い、YouTube APIに落ちましたが、それでも機能しません。
これがdivの私のコードです
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();
}
}
ありがとう、アラ