H5P Video - Wordpress Bootstrap-Modal

I'm using the h5p Wordpress plugin. I used the plugin to create an interactive video.

Then I take the h5p shortcode and include it in a bootstrap modal. The modal is hidden and only shows when I click on a button.

My problem is that when I close the modal the video keeps playing. Is there a way I can stop the video when the modal closes?

Thank you!

 

icc's picture

Unfortunately, the H5P content isn't aware if its parent container is shown or hidden. Though it probably should be there's only one way to get around it. You'll have to figure out when the modal closes and then add the code to stop the video: 

document.querySelector('.h5p-iframe').contentWindow.H5P.instances[0].pause();

You can test the code from you browser's console(Ctrl+Shift+J in Chrome). Paste it and run it while the video is playing to see that it actually pauses the video.

Thank you so much! It's exactly what I needed!

Hello, I have a similar issue as well but on a moodle instance. I've tried running the same code in my console just to test, but it isn't working.

otacke's picture

Hi Dotun!

I am sorry that you're running into trouble. Could you please share a little more information? If the community only knows that "it's not working", nobody will be able to help you.

Cheers,
Oliver