Last active
August 29, 2015 14:13
-
-
Save nekoTheShadow/645d6cc5ab9d762aa7d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id = "popup">ここを押せば再生が始まります</div> | |
<div id = "player" style = "display: none"></div> | |
<script src = "https://www.youtube.com/iframe_api"></script> | |
<script> | |
var player; | |
var onYouTubeIframeAPIReady = function(){ | |
player = new YT.Player("player",{videoId: "dFf4AgBNR1E"}); | |
} | |
var popup = document.getElementById("popup"); | |
popup.style.fontSize = "36pt"; | |
popup.onclick = function(){ | |
if (document.getElementById("player").style.display === "none"){ | |
document.getElementById("player").style.display = "block"; // 表示して | |
popup.innerHTML = "ここを押せば再生が止まります"; // popupを書き換えて | |
player.playVideo(); // 動画再生 | |
}else{ | |
player.stopVideo(); // 動画を止めて | |
popup.innerHTML = "ここを押せば再生が始まります"; // popupを書き換えて | |
document.getElementById("player").style.display = "none"; // 非表示に | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment