Javascript DOM HTML Video pause() Method

Introduction

A video with play and pause buttons:

Click the buttons to play or pause the video.

View in separate window

<!DOCTYPE html>
<html>
<body>
<video id="myVideo">
  <source id="mp4_src" src="video.mp4" type="video/mp4">
  <source id="ogg_src"  src="video.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>//from www.  j av  a2  s. c om
<button onclick="playVid()" type="button">Play Video</button>
<button onclick="pauseVid()" type="button">Pause Video</button>

<script>
var x = document.getElementById("myVideo");

function playVid() {
  x.play();
}

function pauseVid() {
  x.pause();
}
</script>
</body>
</html>

The pause() method halts (pauses) the currently playing video.

element.pause();



PreviousNext

Related