Stop the embedded Plyr video while closing the pop-up modal

Hello all,

I use the Plyr to embed YouTube video in a pop-up modal. However, when I close the pop-up window, while the video disappears, the sound continues to be played in the background.

Do you have any solutions for this?

Thanks a lot!

Here is my site Read-Only:

Hi Kaiting, you could adapt this approach.

Basically you need to set up a mutation observer that detects when your pop-up is hidden, and then have it pause the video using the Plyr API.

1 Like