Background Video Controls

Has anyone written code to pause/play the background video component? I would like to be able to pause the video when it’s out of the viewport and when a button opening another video (in a modal box) is pressed.