Video controls Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Video

Description

The controls property sets or gets whether a video should display standard video controls.

This property reflects the <video> controls attribute.

Set the controls property with the following Values

Value Description
true|false Sets whether a video should have controls displayed

Return Value

A Boolean, returns true if video controls are displayed, otherwise it returns false

Default Value is false

The following code shows how to Enable controls for a video:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<video id="myVideo" width="320" height="240">
  <source src="your.mp4" type="video/mp4">
  <source src="your.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video><br>

<button onclick="enableControls()" type="button">Enable controls</button>
<button onclick="disableControls()" type="button">Disable controls</button>
<button onclick="checkControls()" type="button">Check controls status</button>

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

function enableControls() {//from w  w  w.j av a 2 s .co  m
    x.controls = true;
    x.load();
}

function disableControls() {
    x.controls = false;
    x.load();
}

function checkControls() {
    console.log(x.controls);
}
</script>

</body>
</html>

Related Tutorials