Audio Player Generator
`;
codeOutput.textContent = htmlCode;
}
// Reset player to default settings
function resetPlayer() {
currentPlayer = {
style: 'default',
width: 500,
volume: 80,
primaryColor: '#3498db',
bgColor: '#ffffff',
fontFamily: "'Segoe UI', Tahoma, Geneva, Verdana, sans-serif",
showPlaylist: true,
showVolume: true,
autoPlay: false,
loopPlaylist: false,
tracks: []
};
// Update UI controls
playerStyle.value = 'default';
playerWidth.value = 500;
playerWidthValue.textContent = '500px';
volume.value = 80;
volumeValue.textContent = '80%';
primaryColor.value = '#3498db';
primaryColorHex.value = '#3498db';
primaryColorPreview.style.background = '#3498db';
bgColor.value = '#ffffff';
bgColorHex.value = '#ffffff';
bgColorPreview.style.background = '#ffffff';
fontFamily.value = "'Segoe UI', Tahoma, Geneva, Verdana, sans-serif";
showPlaylist.checked = true;
showVolume.checked = true;
autoPlay.checked = false;
loopPlaylist.checked = false;
// Reset tracks
initializeDefaultTracks();
// Apply changes
updatePlayer();
updateCode();
}
// Export code as downloadable file
function exportCode() {
const htmlCode = codeOutput.textContent;
const blob = new Blob([htmlCode], { type: 'text/html' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'audio-player.html';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
alert('Audio player code downloaded successfully!');
}
});