Stop playing video?

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

I used this js code;

Screenshot;

Could you please help me solve this problem.

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” 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

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

Hope this helps

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

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

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

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.