HTML DOM Video controls Property

HTMLWeb DevelopmentFront End Technology

The HTML DOM Video controls property returns/sets boolean value corresponding to whether the video’s standard controls will be enabled or not.

Following is the syntax −

Returning boolean value - true/false

mediaObject.controls

Setting controls to booleanValue

mediaObject.controls = booleanValue

Here, “booleanValue” can be the following −

booleanValue
Details
true
It defines that video willhave standard controls
false
It defines that video willnot have standard controls

Let us see an example of Video controls property −

Example

<!DOCTYPE html>
<html>
<head>
<title>HTML DOM Video controls</title>
<style>
   * {
      padding: 2px;
      margin:5px;
   }
   form {
      width:70%;
      margin: 0 auto;
      text-align: center;
   }
   input[type="button"] {
      border-radius: 10px;
   }
</style>
</head>
<body>
   <form>
      <fieldset>
         <legend>HTML-DOM-Video-controls</legend>
         <video id="demo" width="320" controls><source                src="http://www.tutorialspoint.com/html5/foo.mp4" type="video/mp4"></video><br>
         <input type="button" onclick="getTrackDetails()" value="Watch Video">
         <input type="text" id="textSelect" placeholder="Full Name...">
         <div id="divDisplay"></div>
      </fieldset>
   </form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   var textSelect = document.getElementById("textSelect");
   var demo = document.getElementById("demo");
   demo.controls = false;
   function getTrackDetails() {
      if(textSelect.value !== ''){
         demo.controls = true;
         divDisplay.textContent = 'Thank you '+textSelect.value;
      }
      else
         divDisplay.textContent = 'Please Provide Full Name to enable video'+textSelect.value;
   }
</script>
</body>
</html>

Output

Clicking ‘Watch Video’ button with empty input field −

Clicking ‘Watch Video’ button with non - empty input field −

raja
Published on 30-Oct-2019 07:04:58
Advertisements