我想制作一个支持替代键盘调音系统的Web应用程序。理想情况下,当您单击键盘上的任一键时,提示音将一直持续到用户再次单击该键为止。目前,它会播放30秒的音频剪辑。如果我可以自动调音,则可以使用更短的声音片段并节省空间!
这是其中一个键的CodePen: https://codepen.io/bmoric/pen/bmdPax
<!DOCTYPE html>
<html>
<head>
<style>
/////////
</style>
<script>
function play288() {
var audio = document.getElementById('audioD');
var text = document.getElementById('play288');
if (audio.paused) {
audio.play();
document.getElementById("play288").style.boxShadow = "inset 3px 3px 5px rgba(0,0,0,.5)";
document.getElementById("play288").style.textShadow = "3px 3px 5px rgba(0,0,0,.5)";
}
else {
audio.pause();
audio.currentTime = 0;
document.getElementById("play288").style.boxShadow = "inset 0px 0px 0px rgba(0,0,0,0)";
document.getElementById("play288").style.textShadow = "0px 0px 0px rgba(0,0,0,.5)";
}
}
</script>
</head>
<body>
<h3 style="color:white;">Perfect 5th Interval Scale</h3>
<audio src="https://webdevgeometrics.com/wp-content/uploads/2018/10/D.288Hz.ogg" id="audioD"></audio>
<div id="play288" onclick="play288()" class="key">D 288Hz</div>
</body>
</html>