How to play background video on click

So I have a site where I have a few background videos, there are 4 and each one is hidden unless an accordion is clicked on. My issue is that the videos constantly auto play, I want the videos to be paused until they are visible. Is there a way to do that, even with code?