
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Video volume Property
The HTML DOM Video volume property returns/sets a number corresponding to current volume level of media.
Syntax
Following is the syntax −
Returning volume as a number
mediaObject.volume
Setting volume to a number
mediaObject.volume = number
NOTE: Number has a max value of ’1.0’ and if ‘0.0’ video volume is min.
Let us see an example of Video volume property −
Example
<!DOCTYPE html> <html> <head> <title>HTML DOM Video volume</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-volume</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(1)" value="Too High (-)"> <input type="button" onclick="getTrackDetails(2)" value="Too Low (+)"> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var demo = document.getElementById("demo"); function getTrackDetails(val) { if(val === 1){ if(demo.volume < 0.2) demo.volume = 0.1; demo.volume -= 0.1; divDisplay.textContent = 'Volume: '+demo.volume; } else{ demo.volume += 0.1; divDisplay.textContent = 'Volume: '+demo.volume; } } </script> </body> </html>
Output
Clicking ‘Too High (-)’ button 2 times. Consider this will decrease the volume button twice −
Now, click ‘Too Low (+)’ button once. Consider this will increase the volume button −
- Related Articles
- HTML DOM Video autoplay Property
- HTML DOM Video buffered Property
- HTML DOM Video controls Property
- HTML DOM Video currentSrc Property
- HTML DOM Video currentTime Property
- HTML DOM Video defaultMuted Property
- HTML DOM Video defaultPlaybackRate Property
- HTML DOM Video duration Property
- HTML DOM Video ended Property
- HTML DOM Video height Property
- HTML DOM Video loop Property
- HTML DOM Video muted Property
- HTML DOM Video networkState Property
- HTML DOM Video paused Property
- HTML DOM Video playbackRate Property

Advertisements