Hide Div After Youtube Video Ends
I am working on a simple one page website for a friend, which contains a YouTube video embed. I'm not very familiar with the YouTube API, but I got the follow to work (see below).
Solution 1:
Assuming your script works, you should just do :
functionstopVideo() {
player.stopVideo();
document.getElementById("player").style.display = "none";
}
As for the detection of the end of the video, you should do :
function onPlayerStateChange(event) {
if(event.data === YT.PlayerState.ENDED) {
stopVideo();
}
}
Post a Comment for "Hide Div After Youtube Video Ends"