user14608313
user14608313

Reputation:

How to pause and unpause a video

I have this code inside

and I have the .css the class myvideo (It doesn't need this code ),it is the design. What I want to know is ,how can I do pause and unpause this video.I try to stop my video and I didn't manage it.If you could help me with it I will be greatful.Thanks

<div class="myvideo" style="left: 6px; top: 0px">
<video id="video-bg-elem" preload="auto" autoplay="true" loop="loop" muted="muted">
<source src="exr.mp4" type="video/mp4">
</video>

Upvotes: 0

Views: 1817

Answers (1)

Francis Chartrand
Francis Chartrand

Reputation: 167

If you want to have control over a video element you must use JavaScript to control it. Here's a great example of how to control a video object from JavaScript: https://www.w3schools.com/tags/av_met_pause.asp

You may need to add another HTML element to control your video. This element must listen to a click event. After that, you will be able to do what you want with the video.

const videoEl = document.getElementById("video-bg-elem");

// Will play the video
videoEl.play();

// Will pause the video
videoEl.pause();

Upvotes: 1

Related Questions