After utilizing various suggestions, I have successfully created a basic audio slider that starts playing sound (at zero volume) when clicked by the user. They can then adjust the volume as needed.
My only challenge is that the volume adjustment only occurs once the user releases the mouse after moving the slider, rather than changing gradually as they drag it. Is there a way to achieve smooth volume adjustments while moving the slider? Any assistance would be greatly appreciated.
JS
var mediaClip;
var volume1;
function init()
{
mediaClip = document.getElementById("mediaClip");
volume1 = document.getElementById("volume1");
mediaClip.play();
}
function setVolume() {
var mediaClip = document.getElementById("mediaClip");
mediaClip.volume = document.getElementById("volume1").value;
}
function play() {
var audio = document.getElementById("mediaClip");
audio.play();
}
HTML
<body onload="init()">
<audio id="mediaClip" src="A Very Brady Special.mp3" style="display:none" allow="autoplay" controls>
<p>Your browser does not support the audio element</p>
</audio>
<input type="range" onchange="setVolume()" id='volume1' min=0 max=1 step=0.01 value='0' onclick="play()">
</body>