Beginner coder here flipping between Javascript and JQuery. I’m working on a customised audio player and have a button that onclick will fade out the music in 3 secs (this is just a working time) but I would like the user to see the countdown of the reducing volume. The code is:
Would show me the volume but no matter where in the main body of the code I place it nothing appears in the div. Can anyone tell me where I’ve gone wrong please or if it is even possible.
Hi
Thanks for replying. I’m afraid I’ve no idea what you mean by ES6 and Unexpected Indent. I’m very new to Javascript coding and just feeling my way around. This code is on my webpage as part of an audio player that I’m designing.
animate provides a step function that give you access to the value of the property being animated. Not really sure how you plan to show the decimal value of the volume property.
Pytutor under Javascript, but the error part referenced python. I’m not really sure why although this has php inside the JS code. I’m guessing that pytutor.com is mostly error checking at this point.
<script>
var audio<?php echo $track;?> = document.getElementById("<?php echo $track;?>");
var slider<?php echo $track;?> = document.getElementById("slider<?php echo $track;?>");
var display<?php echo $track;?> = document.getElementById("display<?php echo $track;?>");
slider<?php echo $track;?>.addEventListener("input", sliderActions);
function sliderActions( )
{
var newVolume = slider<?php echo $track;?>.value;
display<?php echo $track;?>.innerText = newVolume; // range 0 to 100
audio<?php echo $track;?>.volume = newVolume / 100; // range 0 to 1
}
</script>
My issue is the auto fade button always starts from .5 (as I’ve set it). I would like the auto fade button to start from where the user leaves the volume slider value. I have tried to put the variables from the slider script at the volume= part of the auto fade button. I don’t know if I’m using the correct syntax of even if it’s possible. Both scripts are within a form tag and accessing the sql results. Nothing works for me. If someone could point me to the correct way to use a variable out of one script and into another I would be very grateful.