Tag: 自动关闭

FancyBox和Youtube API事件

一旦我正在播放到我的fancybox中的YouTubevideo结束,我正试图发起一个事件。 所以我可以在video结束后自动关闭fancybox。 我有最后一个fancybox版本,我在youtube API上,坚持示例,但似乎ytplayer对象是“未定义”,我无法使其正常工作。 我在互联网上阅读了很多东西,包括这个,这似乎很好: 当youtubevideoID完成时,如何让fancybox自动关闭? 这是我正在使用的代码: JsFiddle $(“.fancybox”).fancybox({ ‘openEffect’ : ‘none’, ‘closeEffect’ : ‘none’, ‘overlayOpacity’ : 0.7, ‘helpers’ : { media : {} }, ‘afterLoad’ : function() { function onYouTubePlayerReady(playerId) { //alert(playerId); //alert(document.getElementById(“myytplayer”)); ytplayer = document.getElementById(“myytplayer”); ytplayer.addEventListener(“onStateChange”, “onytplayerStateChange”); } function onytplayerStateChange(newState) { //alert(“Player’s new state: ” + newState); if (newState == 0){ $.fancybox.close(true); } […]