I have many sounds used in a page and i decided to load them on a sound icon click so it will work on mobile/touch devices. See below the code
var greenBetsound = document.getElementById('greenBet_sound');
jQuery('.soundIcon').click(function(){
if(!jQuery('.soundIcon').hasClass('soundIconOn')){
jQuery('body').addClass('audioOn');
jQuery('.soundIcon').removeClass('soundIconOff').addClass('soundIconOn');
greenBetsound.load();
firstReelStopsound.load();
secondReelStopsound.load();
thirdReelStopsound.load();
fourthReelStopsound.load();
fifthReelStopsound.load();
creditsTranferWithNoClubMeter.load();
bonusGamesStart.load();
jackpotSound.load();
winline1Combsound.load();
winline2Combsound.load();
winline3Combsound.load();
winline4Combsound.load();
winline5Combsound.load();
winline6Combsound.load();
mysterycountsound.load();
}else{
jQuery('body').removeClass('audioOn');
jQuery('.soundIcon').removeClass('soundIconOn').addClass('soundIconOff');
}
});
Here is the markup
<audio id="greenBet_sound" src="sounds/sound21.mp3" preload="auto"></audio>
How can I have them all loaded at once in one line and have a callback on complete of loading so i allow users to navigate into the webpage only after the sounds will be fully loaded?
Thanks.