Skip to content

MRSE435/Spotifyclone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎡 Spotify Clone

A Fully Functional Music Player β€” Built with Pure HTML, CSS & JavaScript

Live Demo GitHub


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.


πŸ“Έ Screenshots

πŸ–₯️ Desktop View

Desktop View

πŸ“± Mobile View β€” Playlist

Mobile Playlist

πŸ“± Mobile View β€” Sidebar Menu

Mobile Sidebar


✨ Features

Feature Description
▢️ Play / Pause 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

πŸš€ Tech Stack

HTML5 CSS3 JavaScript

No frameworks    βœ…
No libraries     βœ…
No React         βœ…
Pure vanilla JS  βœ…
HTML5 Audio API  βœ…

πŸ—‚οΈ Playlist Structure

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/

info.json Structure

{
    "title": "Morning Melodies",
    "description": "Start Your Day Right",
    "songs": [
        "songs/ncs/song1.mp3",
        "songs/ncs/song2.mp3"
    ]
}

πŸ’» Key JavaScript Concepts Used

HTML5 Audio API

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 + "%"
})

Dynamic Playlist Loading From JSON

async function getsongs(folder) {
    let infoFetch = await fetch(`${folder}info.json`)
    let info = await infoFetch.json()
    return info.songs || []
}

Dynamic Playlist Cards

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 β€” Click To Seek

seekbar.addEventListener("click", (e) => {
    let percent = (e.offsetX / seekbar.getBoundingClientRect().width) * 100
    circle.style.left = percent + "%"
    currentsong.currentTime = (percent / 100) * currentsong.duration
})

Seekbar β€” Drag To Scrub

// 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 / Previous Track

next.addEventListener("click", () => {
    let index = songs.indexOf(currentsong.src.split("/").pop())
    if (index + 1 < songs.length) {
        playmusic(songs[index + 1].split("/").pop().replace(".mp3", ""))
    }
})

Mobile Hamburger Menu

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
})

πŸ“± Responsive Design

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

βš™οΈ Local Setup

1. Clone the repo

git clone https://github.com/MRSE435/Spotifyclone
cd Spotifyclone

2. Add your songs

Create 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

3. Open in browser

# Open index.html directly in browser
# OR use Live Server in VS Code
# No backend needed βœ…

πŸ“ Full Project Structure

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
    └── .../

πŸ“š What I Learned

βœ… 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

πŸ‘¨β€πŸ’» Author

Mohammed Owais

BCA Student β€” Presidency College, Bangalore | SGPA: 8.98 / 10

GitHub LinkedIn Portfolio


If you found this project interesting, please consider giving it a ⭐

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors