Salve, questo è uno dei pochi script in jquery che ho trovato per creare un fadeOut del volume per un file audio...
ma vorrei modificarlo in maniera tale che il volume fosse portato a 0 dopo una decina di secondi, qualcuno può aiutarmi?
codice:var audioElement = "audio"; $(audioElement).on('timeupdate', function() { var vol = 1, interval = 100; // 200ms interval if (Math.floor(audioElement.currentTime) == 15) { if (audioElement.volume == 1) { var intervalID = setInterval(function() { // Reduce volume by 0.05 as long as it is above 0 // This works as long as you start with a multiple of 0.05! if (vol > 0) { vol -= 0.8; // limit to 2 decimal places // also converts to string, works ok audioElement.volume = vol.toFixed(2); } else { // Stop the setInterval when 0 is reached clearInterval(intervalID); } }, interval); } } });

Rispondi quotando