jquery - Youtube Video Still Playing When Bootstrap Modal Closes -


i creating website bootstrap can found here - http://www.branchingouteurope.com/digital-spark-testing/

if select video image you'll see modal window open youtube video. problem have when modal window closed video keeps playing. want video stop when modal window closed.

i've looked online , read many solutions none seem work. here mark up...

<span class="main_video"> <div data-toggle="modal" data-target="#mymodal" style="cursor:pointer"> <img src="img/master/video.fw.png" height="81%" width="60%" alt="digital spark video"/> </div> </span>  <div class="modal-dialog"> <div class="modal-content">   <div class="modal-header">     <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>   </div>   <div class="modal-body">   <iframe width="100%" height="100%" src="//www.youtube.com/embed/sifypqjyhv8?rel=0" frameborder="0" allowfullscreen></iframe>   </div> </div> 

`

testing here in firefox 26.0, works expected. when either close modal or click outside of , re-open - video start , stopped.

edit 1

reproduced in chrome, video indeed keeps playing after modal closed.

try these answered questions

stop youtube video jquery?

twitter bootstrap modal stop youtube video

the best way seems to use youtube api stop video. answer uses method available in questions above.

edit 2

this solution seems working.

first, js post: youtube iframe api: how control iframe player that's in html? , include on page.

add js after have loaded above script (just before closing body tag)

<script type="text/javascript">     $('#mymodal').on('hidden.bs.modal', function () {         callplayer('yt-player', 'stopvideo');     }); </script> 

you need add id div containing iframe, below

<div class="modal-body" id="yt-player">     <iframe src="//www.youtube.com/embed/sifypqjyhv8?rel=0&enablejsapi=1" allowfullscreen="" width="100%" frameborder="0" height="100%"></iframe> </div> 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -