so I'm not to knwoledgeable on JavaScript so wouldn't know how to do this. Also from my searching I could only find how to use JavaScript to change the html audio tag volume, but that isn't what I want.
I want to be able to change the volume of this script below. I don't want an actual slider on the page, literally a variable I can change the value for in the script. (This code isn't mine, I found it and it works well for what I need).
var collection=[];
var loadedIndex=0;
function init(audios) {
for(var i=0;i<audios.length;i++) {
var audio = new Audio(audios[i]);
collection.push(audio);
buffer(audio);
}
}
function buffer(audio) {
if(audio.readyState==4)return loaded();
setTimeout(function(){buffer(audio)},100);
}
function loaded() {
loadedIndex++;
if(collection.length==loadedIndex)playLooped();
}
function playLooped() {
var audio=Math.floor(Math.random() * (collection.length));
audio=collection[audio];
audio.play();
setTimeout(playLooped,audio.duration*1000);
}
init([
'songs/1.ogg',
'songs/2.ogg',
]);
The script basically picks one of the two songs at random and then plays it, it's just way to loud and I need some sort of volume adjustment. Thanks