A simple, clean, and functional web-based music player built with HTML, CSS, and Vanilla JavaScript.
This project is a front-end music player application that allows users to play a predefined list of songs. It features basic controls like play, pause, next, and previous, along with a progress bar to track and seek through the currently playing song.
- Playback Controls: Play, Pause.
- Track Navigation: Next and Previous song functionality.
- Progress Bar: Displays song progress and allows seeking.
- Time Display: Shows current playback time and total song duration.
- Dynamic UI Updates: Updates song title, artist, and album art dynamically.
- Auto-Play Next: Automatically plays the next song when the current one finishes.
- Simple & Clean UI: Minimalist design.
- HTML5: For structuring the web page.
- CSS3: For styling the player interface, including responsive design for smaller screens.
- Vanilla JavaScript: For handling player logic, DOM manipulation, and event handling.
- Font Awesome: For player control icons.
- Clone the repository:
git clone https://github.com/awesome-kartikey/music-player.git cd music-player - Ensure you have the necessary assets:
- Place your music files (MP3 format recommended) inside the
music/directory. - Place the corresponding album art images (JPG format recommended) inside the
img/directory. - Important: The JavaScript code (
script.js) expects the audio file and image file for a song to have the same base name (e.g.,song-1.mp3andsong-1.jpg). You'll need to update thesongsarray inscript.jsto match your filenames and desired display names/artists.
// Example entry in script.js const songs = [ { name: "your-song-filename-base", // e.g., 'my-track-1' for 'my-track-1.mp3' and 'my-track-1.jpg' displayName: "Your Song Title", artist: "Your Artist Name", }, // ... add more songs ];
- Place your music files (MP3 format recommended) inside the
- Open the application:
- Simply open the
index.htmlfile in your web browser. No build step or server is required for basic functionality.
- Simply open the
- Click the Play button () to start playing the current song.
- Click the Pause button () to pause the current song.
- Click the Next button () to skip to the next song in the playlist.
- Click the Previous button () to go back to the previous song.
- Click anywhere on the progress bar to jump to that specific point in the song.
- The player will automatically proceed to the next song when the current one finishes.