document.addEventListener("DOMContentLoaded", function() {
var audioPlayer = document.getElementById("audioPlayer");
var closeButton = document.getElementById("closeButton");
// Stop audio and hide player when close button is clicked
closeButton.addEventListener("click", function() {
audioPlayer.pause(); // Stop the audio
document.getElementById("musicPlayer").style.display = "none"; // Hide the player
});
// Ensure the pause icon is active on load if autoplay is set
if (audioPlayer.autoplay) {
audioPlayer.play().catch(function(error) {
audioPlayer.pause();
});
}
});