lezzo.org/bocciofila/cori.js

20 lines
469 B
JavaScript
Raw Permalink Normal View History

2023-07-05 15:55:12 +01:00
var audioFiles = [];
var numAudioFiles = 14;
// Preload the audio files
for (var i = 1; i <= numAudioFiles; i++) {
var coro = new Audio("cheers/" + i + ".ogg");
audioFiles.push(coro);
}
function coro() {
// Generate a random index between 0 and the number of audio files
var randomIndex = Math.floor(Math.random() * numAudioFiles);
// Get the randomly selected audio from the array
var c = audioFiles[randomIndex];
// Play the audio
c.play();
}