Video doesn't stop after closing modal

I have a modal with a embedded video on https://videoposters.nl. It works quite well but there is one issue. When I close the modal during playing the video, the video doesn't stop but it keeps on playing. I tried many related scrips but nothing works for me. Please can anybody help me to solve it?

related post

Add an ID on your iframe so you can find and reference it.

bijvoorbeeld in jouw geval

<iframe id="Mijnvideospeler" class="embed-responsive-item" src="https://videoposters.nl/videoposters.mp4">

in a JS-file add this

$(document).ready(function() {
  $('#modal-video').on('hide.bs.modal', () => {
      $('#Mijnvideospeler').attr('src', '');
   });
});

You don't even need to add an ID. Just create a new JS file with the following code.

$('.modal').on('hide.bs.modal', function() { var memory = $(this).html(); $(this).html(memory); })

Add this in the JS-file

$(document).ready(function() {
  $('#modal-video').on('hide.bs.modal',  function ()  {
    $('#Mijnvideospeler').attr('src', '');
   });
  $('#modal-video').on('show.bs.modal',  function ()  {
    $('#Mijnvideospeler').attr('src', 'https://videoposters.nl/videoposters.mp4');
   });
});

in the first example there is no video if you open the modal a second time

here is an example

@Printninja

your code doesn’t stop the video after closing modal

Hi, thanks for all the effort (and support in dutch:)! Your example works exactly what I need. I add the ID to Responsive Embed attributes, but that doesn't work. Should I convert it to html? Is there an option to avoid converting to html? I prefer to keep the BSS component structure.

You can ignore my previous reply. It fixed already! Perfect solution. Thanks a lot!

Graag gedaan

@kuligaposten

It does on my Windows 7 machine in the latest versions of Firefox and Chrome, as well as on my Android in both browsers. Haven't checked it on iOS or Safari

Try it yourself.,,, http://thelightwavegroup.com/wc/west-coast-aikido-blog.html

@Printninja

It works on your site because of the play button you must click on before the YouTube video start to play, but if you change your embedded video to albertheres's videoposter https://videoposters.nl/videoposters.mp4 then when you close the modal the iframe reload the video and start to play the video again from the beggining

@kuligaposten

Ahh, I see what you mean.

Okay, then I leave this issue in your capable hands, as I will never have an instance where I need to load a video from https://videoposters.nl/videoposters.mp4 in a modal.