HTML onratechange屬性是事件屬性,如果更改音頻/視頻的播放速度,則會發生此事件。 playbackRate屬性用於設置或返回音頻/視頻的當前播放速度。
用法:
<element onratechange="myScript">
屬性值:此屬性包含單值腳本,該腳本在onratechanged事件屬性調用時起作用。 <audio>和<video>標簽支持此屬性。
Example:
<!DOCTYPE html>
<html>
<head>
<title>
HTML onratechange Attribute
</title>
</head>
<body>
<center>
<h1 style="color:green">
GeeksforGeks
</h1>
<h2>HTML onratechange Attribute</h2>
<video id="vidID"
width="400" height="400"
autoplay controls>
<source src=
"https://media.geeksforgeeks.org/wp-content/uploads/20190401140735/g4g2.mp4"
type="video/mp4">
</video>
<br>
<button onclick="speed()" type="button">
Slow motion
</button>
<script>
// Get the video element with id="myVideo"
var x = document.getElementById("vidID");
function speed() {
x.playbackRate = 0.5;
}
x.addEventListener("ratechange", GFGfun);
function GFGfun() {
alert("Playing speed changed");
}
</script>
</center>
</body>
</html>
輸出:
支持的瀏覽器:
- 穀歌瀏覽器
- IE瀏覽器
- Firefox
- 蘋果Safari
- Opera
相關用法
- HTML onratechange事件用法及代碼示例
- HTML <html> xmlns屬性用法及代碼示例
- HTML scoped屬性用法及代碼示例
- HTML <th> valign屬性用法及代碼示例
- HTML <col> align屬性用法及代碼示例
- HTML poster屬性用法及代碼示例
- HTML Class屬性用法及代碼示例
- HTML style屬性用法及代碼示例
- HTML oninvalid用法及代碼示例
- HTML <select> autocomplete屬性用法及代碼示例
- HTML <table> bgcolor屬性用法及代碼示例
- HTML onsubmit用法及代碼示例
- HTML onunload用法及代碼示例
- HTML srcdoc屬性用法及代碼示例
- HTML Marquee truespeed用法及代碼示例
- HTML onkeyup用法及代碼示例
- HTML ondrop用法及代碼示例
- HTML <td> abbr屬性用法及代碼示例
- HTML onpageshow用法及代碼示例
- HTML reversed屬性用法及代碼示例
- HTML readonly屬性用法及代碼示例
- HTML required屬性用法及代碼示例
- HTML onsearch用法及代碼示例
注:本文由純淨天空篩選整理自ManasChhabra2大神的英文原創作品 HTML onratechange Attribute。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。