Spaces:
Running
Running
File size: 1,262 Bytes
364d73c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | // Initialize audio context for sound manipulation
document.addEventListener('DOMContentLoaded', () => {
// Initialize all audio elements
const audioElements = document.querySelectorAll('audio');
audioElements.forEach(audio => {
// Add visualizer to each audio element
const container = audio.parentElement;
const visualizer = document.createElement('div');
visualizer.className = 'sound-wave mt-4';
visualizer.innerHTML = `
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
`;
container.appendChild(visualizer);
// Show visualizer only when playing
audio.addEventListener('play', () => {
visualizer.style.display = 'flex';
});
audio.addEventListener('pause', () => {
visualizer.style.display = 'none';
});
});
// Handle the play mix button
const playMixButton = document.querySelector('button');
if (playMixButton) {
playMixButton.addEventListener('click', () => {
// In a real app, this would mix the audio
alert('Mixing sounds... (This is a demo)');
});
}
}); |