Minimalist 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>Minimalist Audio Player</title> <style> body { font-family: 'Arial', sans-serif; background-color: #f5f5f5; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; color: #333; } .audio-player { background: #fff; border: 1px solid #ccc; border-radius: 10px; padding: 20px; display: flex; align-items: center; gap: 15px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); transition: all 0.3s ease; } .audio-player:hover { box-shadow: 0 0 20px rgba(0, 0, 0, 0.2); } .audio-player button { background: none; border: 1px solid #333; border-radius: 50%; color: #333; width: 50px; height: 50px; font-size: 24px; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: all 0.3s ease; } .audio-player button:hover { background-color: #333; color: #fff; } .audio-player button:active { background-color: #555; color: #fff; } .audio-player .progress-bar { position: relative; flex: 1; height: 5px; background-color: #ddd; border-radius: 5px; overflow: hidden; cursor: pointer; } .audio-player .progress-bar .progress { background-color: #333; height: 100%; width: 0; transition: width 0.1s linear; } .audio-player .time { min-width: 50px; text-align: right; } .display{display: none;} </style> </head> <body> <div class="audio-player"> <button type="button" id="play-pause"><span id="play-icon">▶️</span><span id="pause-icon" class="display">⏸️</span></button> <div class="progress-bar" id="progress-bar"> <div class="progress" id="progress"></div> </div> <div class="time" id="current-time">0:00</div> </div> <audio id="audio" src="your-audio-file.mp3"></audio> <script> const playPauseButton = document.getElementById('play-pause'); const playIcon = document.getElementById('play-icon'); const pauseIcon = document.getElementById('pause-icon'); const audio = document.getElementById('audio'); const progressBar = document.getElementById('progress-bar'); const progress = document.getElementById('progress'); const currentTimeDisplay = document.getElementById('current-time'); playPauseButton.addEventListener('click', () => { if (audio.paused) { audio.play(); playIcon.style.display = 'none'; pauseIcon.style.display = 'inline'; } else { audio.pause(); playIcon.style.display = 'inline'; pauseIcon.style.display = 'none'; } }); audio.addEventListener('timeupdate', () => { const currentTime = audio.currentTime; const duration = audio.duration; const progressPercent = (currentTime / duration) * 100; progress.style.width = progressPercent + '%'; const minutes = Math.floor(currentTime / 60); const seconds = Math.floor(currentTime % 60); currentTimeDisplay.textContent = `${minutes}:${seconds < 10 ? '0' : ''}${seconds}`; }); progressBar.addEventListener('click', (e) => { const clickX = e.offsetX; const width = progressBar.clientWidth; const duration = audio.duration; audio.currentTime = (clickX / width) * duration; }); </script> </body> </html>