![]() |
Definition and Usage
The Applies to
The
Browser Support
The
|
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<audio id="myAudio" controls onratechange="myFunction()"> <source src="https://file-examples.com/wp-content/storage/2017/11/file_example_MP3_700KB.mp3" type="audio/ogg"> <source src="https://file-examples.com/wp-content/storage/2017/11/file_example_MP3_700KB.mp3" type="audio/mpeg"> Your browser does not support the audio element.
</audio>
<p id="demo">Change the speed of the audio</p>
<input type="range" min="0.5" max="3" step="0.1" value="1"oninput="changeRate(this)">
<script>
function myFunction() { document.getElementById("demo").innerHTML = "The audio's speed is " + document.getElementById("myAudio").playbackRate;
}
function changeRate(obj) { document.getElementById("myAudio").playbackRate = obj.value;
}
</script>
<p>This example demonstrates how to use the "onratechange" attribute on an AUDIO element.</p>
</body>
</html>
Example:
HTML
<!DOCTYPE html>
<html>
<body>
<video id="myVideo" width="320" height="176" controls onratechange="myFunction()"> <source src="https://www.sample-videos.com/video321/mp4/240/big_buck_bunny_240p_30mb.mp4" type="video/mp4"> <source src="https://www.sample-videos.com/video321/mp4/240/big_buck_bunny_240p_30mb.mp4" type="video/ogg"> Your browser does not support HTML5 video.
</video>
<p id="demo">Change the speed of the video</p>
<input type="range" min="0.1" max="3" step="0.1" value="1"oninput="changeRate(this)">
<script>
function myFunction() { document.getElementById("demo").innerHTML = "The video's speed is " + document.getElementById("myVideo").playbackRate;
}
function changeRate(obj) { document.getElementById("myVideo").playbackRate = obj.value;
}
</script>
<p>This example demonstrates how to use the "onratechange" attribute on a VIDEO element.</p>
<p>Video courtesy of <a href="https://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p>
</body>
</html>
html onratechange attribute |
How to Run "myFunction" when the audio changes the rate - HTML onratechange Attribute | HTML Attribute |
How to Run "myFunction" when the video changes the rate - HTML onratechange Attribute | HTML Attribute |
Type
: |
Develop |
Category
: |
Web Tutorial |
Sub Category
: |
HTML Attribute |
Uploaded by
: |
Admin |
Read Article https://horje.com/learn/1434/reference