Horje
How to create HTML Video - Methods, Properties, and Events using Javascript

This tutorial will add some options.

Such as:
  1. Video Play/Pause button.
  2. Video Play Big
  3. Video Play Small
  4. Video Play Normal

The HTML DOM defines methods, properties, and events for the element.

This allows you to load, play, and pause videos, as well as setting duration and volume.

There are also DOM events that can notify you when a video begins to play, is paused, etc.


Example of HTML Video - Methods, Properties, and Events using Javascript

Example: Using JavaScript
index.html
Example: HTML
<!DOCTYPE html> 
<html> 
<body> 

<div style="text-align:center"> 
  <button onclick="playPause()">Play/Pause</button> 
  <button onclick="makeBig()">Big</button>
  <button onclick="makeSmall()">Small</button>
  <button onclick="makeNormal()">Normal</button>
  <br><br>
  <video id="video1" width="420">
    <source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
    <source src="https://www.w3schools.com/html/mov_bbb.mp4" type="video/ogg">
    Your browser does not support HTML video.
  </video>
</div> 

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

function playPause() { 
  if (myVideo.paused) 
    myVideo.play(); 
  else 
    myVideo.pause(); 
} 

function makeBig() { 
    myVideo.width = 560; 
} 

function makeSmall() { 
    myVideo.width = 320; 
} 

function makeNormal() { 
    myVideo.width = 420; 
} 
</script> 

<p>Video courtesy of <a href="https://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p>

</body> 
</html>

Output should be:

Example of HTML Video - Methods, Properties, and Events using Javascript
Reffered: https://www.w3schools.com/html/html5_video.asp





Related Articles
What is HTML Input Attributes HTML Input Attributes
How to create HTML The value Attribute HTML Input Attributes
How to create HTML readonly Attribute HTML Input Attributes
How to create HTML disabled Attribute in input HTML Input Attributes
How to edit HTML size Attribute in input HTML Input Attributes
How to create HTML maxlength Attribute in input HTML Input Attributes
How to create HTML min and max Attributes HTML Input Attributes
How to create HTML multiple Attribute HTML Input Attributes
How to build HTML pattern Attribute in input HTML Input Attributes
How to set HTML placeholder Attribute HTML Input Attributes
How to create HTML required Attribute in input HTML Input Attributes
How to create HTML step Attribute in input HTML Input Attributes
How to set HTML autofocus Attribute in input HTML Input Attributes
How to add height and width Attributes in HTML Input HTML Input Attributes
How to create HTML list Attribute in input HTML Input Attributes
How to add HTML autocomplete Attribute in Input HTML Input Attributes
What is HTML Input form Attributes HTML Input Attributes
How to create HTML form Attribute in Input HTML Input Attributes
How to set HTML form action Attribute in Input HTML Input Attributes
How to set HTML formenctype Attribute in input HTML Input Attributes
How to set HTML form method Attribute in Input HTML Input Attributes
How to set HTML form target Attribute in Input HTML Input Attributes
How to set HTML formnovalidate Attribute in Input HTML Input Attributes
How to set HTML novalidate Attribute in Input HTML Input Attributes
How to create HTML Video - Methods, Properties, and Events using Javascript HTML Input Attributes

Single Articles
Example of HTML Video - Methods, Properties, and Events using JavascriptHTML Input Attributes

Read Full:
HTML Input Attributes
Category:
Web Tutorial
Sub Category:
HTML Input Attributes
Uploaded:
10 months ago
Uploaded by:
Admin
Views:
23



Share on: