HTML DOM Video volume Property
The Video volume property is used for setting or returning the audio volume of a video. The range of the values accepted by the Video volume property lies between 0.0 (silent) and 1.0 (loudest).
Syntax:
- Return the volume property:
videoObject.volume
videoObject.volume = number
Property Values:
- 1.0: This is the highest volume. It is also the default value.
- 0.5: It is used to specify half volume.
- 0.0: It is used to specify zero volume/ mute/ silent.
Return: The Video volume property returns a number that represents the volume of the video.
The below program illustrates the Video Volume property:
Example: Setting the video volume to 50%.
HTML
<!DOCTYPE html>
< html >
< head >
< title >
DOM Video volume Property
</ title >
</ head >
< body style = "text-align: center" >
< h1 style = "color: green" >
GeeksforGeeks
</ h1 >
< h2 style = "font-family: Impact" >
Video volume Property
</ h2 >
< br >
< video id = "Test_Video" width = "360"
height = "240" controls>
< source src =
type = "video/mp4" >
< source src =
type = "video/ogg" >
</ video >
< p >
To set the volume of the video
track to 50%, double click the
"Set Volume" button.
</ p >
< br >
< p >
To return the volume of the
video track, double click
the "Return Volume" button.
</ p >
< br >
< button ondblclick = "My_Video()" >
Set Volume
</ button >
< button ondblclick = "R_Volume()" >
Return Volume
</ button >
< script >
let v =
document.getElementById("Test_Video");
function My_Video() {
v.volume = 0.5;
}
function R_Volume() {
alert(v.volume);
}
</ script >
</ body >
</ html >
|
Output:
Supported Browsers: The browser supported by HTML DOM Video volume Property are listed below:
- Google Chrome 1 and above
- Edge 12 and above
- Internet Explorer 9 and above
- Firefox 3.5 and above
- Opera 12.1 and above
- Apple Safari 3.1 and above
Last Updated :
26 Jun, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...