I was looking for something similar in a button that would stop the video before closing a modal window. While I ended up using innerHTML to effectively erase the video link, Charles L posted code for controlling the video.
Copied from stop-pause-video-when-modal-is-closed-not-using-sign
var video = document.createElement("video");
video.setAttribute("src", "nameOfFile.ogg");
Then you can do something like:
video.pause();
video.currentTime = 0;
From w3Schools:
var vid = document.getElementById("myVideo");
function playVid() {
vid.play();
}
function pauseVid() {
vid.pause();
}
You can then call these functions from inside your closing/open modal functions
-
This reply was modified 6 years, 7 months ago by
jolanxbl. Reason: cleaning
@jolanxbl Thanks for your reply.
I have followed this solution. But it doesn’t work.
I think I need to find the video form element using JavaScript instead of to create a new element. But I can’t find that video element using the WordPress Elementor. That is why I posted this issue.
Do you have any idea?