A pixel-accurate Spotify UI clone with fully working music playback β multiple mood-based playlists, play/pause, next/previous, seekbar drag, and real-time progress β built entirely in vanilla JavaScript with zero frameworks or libraries.
| Feature | Description |
|---|---|
| Toggle music playback with icon switching | |
| βοΈ Next / Previous | Navigate between tracks in current playlist |
| π΅ Seekbar | Click anywhere on seekbar to jump to that position |
| π±οΈ Drag Seekbar | Drag the circle on seekbar to scrub through song |
| β±οΈ Live Time Display | Shows current time and total duration in real time |
| π Your Library | Sidebar showing all songs in current playlist |
| π¨ Mood Playlists | Multiple playlist cards β Angry, Chill, Dark, Love, NCS and more |
| π± Fully Responsive | Hamburger menu slides in sidebar on mobile |
| π Dark Theme | Spotify's signature dark UI recreated accurately |
| π JSON Based | Each playlist reads from its own info.json file |
No frameworks β
No libraries β
No React β
Pure vanilla JS β
HTML5 Audio API β
Each playlist folder contains:
songs/
βββ ncs/
β βββ info.json β playlist metadata
β βββ cover.jpg β playlist cover image
β βββ song1.mp3 β audio files
βββ Angry_(mood)/
β βββ info.json
β βββ cover.jpg
β βββ song1.mp3
βββ Chill_(mood)/
βββ Dark_(mood)/
βββ Love_(mood)/
βββ Bright_(mood)/
βββ Funky_(mood)/
βββ Uplifting_(mood)/
βββ Diljit/
βββ karan aujla/
βββ cs/
βββ Get up/
{
"title": "Morning Melodies",
"description": "Start Your Day Right",
"songs": [
"songs/ncs/song1.mp3",
"songs/ncs/song2.mp3"
]
}const currentsong = new Audio()
// Load and play a track
currentsong.src = `${currfolder}` + track + ".mp3"
currentsong.play()
// Track real time progress
currentsong.addEventListener("timeupdate", () => {
document.querySelector(".songtime").innerHTML =
`${secondsToMinutesSeconds(currentsong.currentTime)}
: ${secondsToMinutesSeconds(currentsong.duration)}`
// Move seekbar circle
document.querySelector(".circle").style.left =
(currentsong.currentTime / currentsong.duration) * 100 + "%"
})async function getsongs(folder) {
let infoFetch = await fetch(`${folder}info.json`)
let info = await infoFetch.json()
return info.songs || []
}async function displayalbums() {
for (const folder of folderNames) {
let info = await fetch(`./songs/${folder}/info.json`)
// Creates card with title, description and cover image
// Adds click listener to load that playlist
}
}seekbar.addEventListener("click", (e) => {
let percent = (e.offsetX / seekbar.getBoundingClientRect().width) * 100
circle.style.left = percent + "%"
currentsong.currentTime = (percent / 100) * currentsong.duration
})// Mouse down β start dragging
circle.addEventListener("mousedown", () => { isDragging = true })
// Mouse move β update position while dragging
document.addEventListener("mousemove", (e) => {
if (isDragging) {
let offsetX = e.clientX - seekbar.getBoundingClientRect().left
let percent = (offsetX / seekbar.getBoundingClientRect().width) * 100
circle.style.left = percent + "%"
currentsong.currentTime = (percent / 100) * currentsong.duration
}
})
// Mouse up β stop dragging
document.addEventListener("mouseup", () => { isDragging = false })next.addEventListener("click", () => {
let index = songs.indexOf(currentsong.src.split("/").pop())
if (index + 1 < songs.length) {
playmusic(songs[index + 1].split("/").pop().replace(".mp3", ""))
}
})document.querySelector(".hamburger").addEventListener("click", () => {
document.querySelector(".left").style.left = 0 // slide in
})
document.querySelector(".closebutton").addEventListener("click", () => {
document.querySelector(".left").style.left = "-120%" // slide out
})Desktop β Sidebar always visible
Multi-column playlist grid
Full player controls
Mobile β Hamburger menu (β°)
Sidebar slides in from left
Single column layout
Compact bottom player
git clone https://github.com/MRSE435/Spotifyclone
cd SpotifycloneCreate a folder inside songs/
Add your .mp3 files
Create info.json with title, description, songs array
Add cover.jpg
Add folder name to folderNames array in script.js
# Open index.html directly in browser
# OR use Live Server in VS Code
# No backend needed β
Spotifyclone/
βββ index.html β main HTML structure
βββ style.css β all styling + responsive design
βββ script.js β all music logic + DOM manipulation
βββ images/ β UI icons (play, pause, next, prev)
β βββ play.svg
β βββ pause.svg
β βββ playbutton.svg
β βββ music.svg
βββ songs/ β all playlist folders
βββ ncs/
β βββ info.json
β βββ cover.jpg
β βββ *.mp3
βββ .../
β
HTML5 Audio API β play, pause, timeupdate, currentTime
β
Fetch API β loading JSON data dynamically
β
DOM manipulation β creating elements dynamically
β
Event driven programming β click, mousedown, mousemove, mouseup
β
Drag implementation β isDragging pattern with mouse events
β
CSS Flexbox β complex sidebar + main layout
β
Media queries β mobile responsive hamburger menu
β
Async/Await β fetching playlist data
β
Array methods β indexOf for next/previous logic


