I have this code set up so that when the user clicks on the .close-video
div, another div (#feat-video
) fades out. However, the problem is that the div contains a YouTube video and the video keeps playing even after closing the div. I'm wondering if there is a way I can possibly simulate a keypress action (spacebar) when .close-video
is clicked so that the video stops playing. Is there some way to incorporate it into this code? I tried incorporating .keypress but was unsuccessful and I'm not even sure if that's the correct event to use.
$('.close-video').click(function( e ){
e.preventDefault();
$('#feat-video').fadeOut(500).hide();
$('.video-play-container').fadeIn(500).show();
});
Here is a graphic I made to illustrate.
HTML
<section id="intro" role="banner">
<div class="section-wrap">
<span class="tagline">Two Artists. Two Styles. One Remix</span>
<div class="video-play-container">
<div class="video-play-border">
<div class="video-play"></div>
</div>
</div>
<div id="feat-video" style="display:none">
<span class="close-video"></span>
<?php print TubePressPro::getHtmlForShortcode('youtubeHideBlackBars="true"'); ?>
</div>
</div><!-- .section-wrap -->
</section><!-- #intro -->
Edit: Here's the output for the iframe which embeds the YouTube video.
<iframe id="tubepress-video-object-434992883" data-videoid="hSPnHlDDAsc" data-playerimplementation="youtube" data-videoprovidername="youtube" class="youtube-player" type="text/html" width="940" height="530" src="https://www.youtube.com/embed/hSPnHlDDAsc?wmode=opaque&autohide=2&autoplay=1&enablejsapi=1&fs=1&loop=0&modestbranding=1&rel=0&showinfo=0&origin=http%3A%2F%2Fstaging.site.com" frameborder="0" allowfullscreen=""></iframe>