Retro Themed Audio Player - MeggiTools
Run
Toggle Theme
Share Link
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Retro Themed Audio Player</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"> <style> body { display: flex; justify-content: center; align-items: center; height: 100vh; background: #333; font-family: 'Courier New', monospace; } .audio-player { background: #000; border: 2px solid #00ff00; border-radius: 10px; padding: 20px; box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5); text-align: center; max-width: 350px; width: 100%; color: #00ff00; } .audio-player img { width: 80px; height: 80px; border-radius: 10%; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5); margin-bottom: 20px; } .audio-player audio { width: 100%; margin-bottom: 10px; outline: none; border: none; background: none; } .controls { display: flex; justify-content: center; align-items: center; gap: 10px; } .controls button { background: #00ff00; border: 1px solid #000; border-radius: 5px; width: 40px; height: 40px; font-size: 18px; color: #000; cursor: pointer; outline: none; transition: background 0.3s ease; } .controls button:hover { background: #00cc00; } .progress-container { position: relative; height: 8px; background: #555; border-radius: 4px; overflow: hidden; margin: 15px 0; } .progress { height: 100%; width: 0; background: #00ff00; border-radius: 4px; transition: width 0.1s; } .time { font-size: 12px; } .emoji { position: absolute; bottom: 10px; right: 10px; font-size: 16px; } </style> </head> <body> <div class="audio-player"> <img src="https://i.imgur.com/ZXBtVw7.jpg" alt="Audio Cover"> <audio id="audio" src="https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3"></audio> <div class="controls"> <button type="button" id="playPauseBtn" title="Play"><i class="fas fa-play"></i></button> <button type="button" id="stopBtn" title="Stop"><i class="fas fa-stop"></i></button> </div> <div class="progress-container"> <div class="progress"></div> </div> <div class="time"> <span id="currentTime">0:00</span> / <span id="duration">0:00</span> </div> <div class="emoji">🎶</div> </div> <script> const audio = document.getElementById('audio'); const playPauseBtn = document.getElementById('playPauseBtn'); const stopBtn = document.getElementById('stopBtn'); const progressContainer = document.querySelector('.progress-container'); const progress = document.querySelector('.progress'); const currentTimeEl = document.getElementById('currentTime'); const durationEl = document.getElementById('duration'); playPauseBtn.addEventListener('click', () => { if (audio.paused) { audio.play(); playPauseBtn.innerHTML = '<i class="fas fa-pause"></i>'; } else { audio.pause(); playPauseBtn.innerHTML = '<i class="fas fa-play"></i>'; } }); stopBtn.addEventListener('click', () => { audio.pause(); audio.currentTime = 0; playPauseBtn.innerHTML = '<i class="fas fa-play"></i>'; }); audio.addEventListener('timeupdate', () => { const progressPercent = (audio.currentTime / audio.duration) * 100; progress.style.width = `${progressPercent}%`; const minutes = Math.floor(audio.currentTime / 60); const seconds = Math.floor(audio.currentTime % 60); currentTimeEl.textContent = `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`; }); audio.addEventListener('loadedmetadata', () => { const minutes = Math.floor(audio.duration / 60); const seconds = Math.floor(audio.duration % 60); durationEl.textContent = `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`; }); progressContainer.addEventListener('click', (e) => { const width = progressContainer.clientWidth; const clickX = e.offsetX; const duration = audio.duration; audio.currentTime = (clickX / width) * duration; }); </script> </body> </html>