# Stop playing video?

**URL:** https://forum.pinegrow.com/t/stop-playing-video/1974
**Category:** General
**Created:** [June 16, 2018, 6:10pm UTC](https://forum.pinegrow.com/t/stop-playing-video/1974 "2018-06-16T18:10:16Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![trueman](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/trueman/32/1162_2.png) [@trueman](https://forum.pinegrow.com/u/trueman)
#### Post date: [June 16, 2018, 6:10pm UTC](https://forum.pinegrow.com/t/stop-playing-video/1974/1 "2018-06-16T18:10:17Z")

</div>

I add “responsive media” video into the modal, but the video does not stop when I close it.

I used this js code;

> **[How to stop playing video when Bootstrap Modal is closed - Pinegrow Web Editor...](http://docsbeta.pinegrow.com/how-to-stop-playing-video-when-bootstrap-modal-is-closed/)**
>
> Use this piece of code to stop playing videos embedded in Bootstrap modals when the modal is closed.

Screenshot;

 ![](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/3/3ef3995276d5060a50defa54fd3c6d3775fed50e.png)

Could you please help me solve this problem.

---

<div class="post-metadata">

### Author: ![gzirfas](https://avatars.discourse-cdn.com/v4/letter/g/f6c823/32.png) [@gzirfas](https://forum.pinegrow.com/u/gzirfas)
#### Post date: [June 23, 2018, 3:05am UTC](https://forum.pinegrow.com/t/stop-playing-video/1974/2 "2018-06-23T03:05:19Z")

</div>

This problem is a total enigma. I have found a solution that works for me but am having trouble inserting \< pre\> text in this document. Maybe someone can help me with that, in the meantime I have found a bad way to do it below.

> ```
> $('#modalYT').on('hidden.bs.modal', function () {
> var src = $(this).find('iframe').attr('src');
> $(this).find('iframe').attr('src', '');
> $(this).find('iframe').attr('src', src);
> });
> ```

> \< !-- Button trigger modal–\>  
> \< button type=“button” class=“btn btn-primary” data-toggle=“modal” data-target=“#modalYT”\>How to Setup HALO, HemoFLUOR or HemoLIGHT Hematopoietic Research Assays\< /button\>  
> \< !–Modal: modalYT–\>  
> \< div class=“modal fade” id=“modalYT” tabindex=“-1” role=“dialog” aria-labelledby=“myModalLabel” aria-hidden=“true”\>  
> \< div class=“modal-dialog modal-lg” role=“document”\>  
> \< !–Content–\>  
> \< div class=“modal-content”\>  
> \< !–Body–\>  
> \< div class=“modal-body mb-0 p-0”\>  
> \< div class=“embed-responsive embed-responsive-16by9 z-depth-1-half”\>  
> \< iframe class=“embed-responsive-item” src=“[YouTube](https://www.youtube.com/embed/o02zOgj5oG0)” frameborder=“0” allowfullscreen\>  
> \< /div\>  
> \< !–Footer–\>  
> \< div class=“modal-footer justify-content-center flex-column flex-md-row”\>  
> \< div id=“videolinks”\>  
> \< hr\>  
> \< span class=“assays”\>\< /span\>\< a href=“HALO.php”\>Halo®HemoFLUOR™\< /a\>\< a href=“HemoLIGHT.php”\>HemoLIGHT™\< br\>\< br\>  
> \< button type=“button” class=“btn btn-outline-primary btn-rounded btn-md ml-4” data-dismiss=“modal”\>Close\< /button\> \< /div\>  
> \< /div\>  
> \< /div\>  
> \< !–/.Content–\>  
> \< /div\>  
> \< /div\>

You must give your modal an ID, in this case mine was modalYT  
The only problem is that the script relies on it being in an iframe and UNLOADS the video when the modal closes instead of pausing it, so if they reopen it they are back at the beginning.

sample at  
[http://preferred-cell-systems.com/videos-modal.php](http://preferred-cell-systems.com/videos-modal.php)

notice the accordions do not stop playing, but the orange one at the bottom (the model) does.

Hope this helps

---

<div class="post-metadata">

### Author: ![trueman](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/trueman/32/1162_2.png) [@trueman](https://forum.pinegrow.com/u/trueman)
#### Post date: [June 25, 2018, 1:47am UTC](https://forum.pinegrow.com/t/stop-playing-video/1974/3 "2018-06-25T01:47:20Z")

</div>

Thank you for the answer gzirfas.  
Your code working html.  
But I export theme wordpress, not working.

---

<div class="post-metadata">

### Author: ![schpengle](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/schpengle/32/238_2.png) [@schpengle](https://forum.pinegrow.com/u/schpengle)
#### Post date: [June 26, 2018, 11:30am UTC](https://forum.pinegrow.com/t/stop-playing-video/1974/4 "2018-06-26T11:30:40Z")

</div>

@gzirfas, This post will help you to copy and paste code into the forum

> [@Help for composing message syntax in this forum posts](https://forum.pinegrow.com/t/help-for-composing-message-syntax-in-this-forum-posts/1826):
>
> There is a user guide for using this forum? In my case, there is a specific help for composing/formatting a message? Eg: how can I include parts of html code in posts? tks in advance.

---

<div class="post-metadata">

### Author: ![gzirfas](https://avatars.discourse-cdn.com/v4/letter/g/f6c823/32.png) [@gzirfas](https://forum.pinegrow.com/u/gzirfas)
#### Post date: [June 26, 2018, 5:08pm UTC](https://forum.pinegrow.com/t/stop-playing-video/1974/5 "2018-06-26T17:08:50Z")

</div>

THANK YOU FOR THIS. I tested it out and it will make life way easier.

---

<div class="post-metadata">

### Author: ![gzirfas](https://avatars.discourse-cdn.com/v4/letter/g/f6c823/32.png) [@gzirfas](https://forum.pinegrow.com/u/gzirfas)
#### Post date: [June 26, 2018, 5:10pm UTC](https://forum.pinegrow.com/t/stop-playing-video/1974/6 "2018-06-26T17:10:00Z")

</div>

I haven’t tried using it in wordpress, Most of my sites are custom built but I will see if there is something making it not work with putting in it wordpress.
