I have an autofade button attached to each instance of my audio tracks:
<input type="button" id="autofadebtn<?php echo $track;?>" value="Fade Out"
onclick="$(document).ready(function()
{
$('#<?php echo $track;?>')[0].volume = .5;
$('#<?php echo $track;?>').animate({volume: 0}, 30000);
});
$('#<?php echo $track;?>').promise().done(function() {
$('#<?php echo $track;?>').trigger('pause');
});
"
>
I also have a volume slider:
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
}
My issue is that I would like my autofade button to start at the volume the user moves the volume slider to. Currently the auto fade starts at .5. I can’t work out which variable to use from the volume slider. The autofade button is within the input tag whilst the volume slider script is at the bottom of the page.
I’ve tried replacing the volume = .5 in the autofade with the named variables from the volume slider but each time the autofade stops working.