Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added covers/11.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Spotify</title>
<link rel="stylesheet" href="style.css">
</head>
<link rel="icon" href="logo.png" type="images/png">
</head>
<body>
<nav>
<ul>
<li class="brand"><img src="logo.png" alt="Spotify"> Spotify</li>
<li>Home</li>
<li>About</li>
<li>Profile</li>
</ul>
</nav>

Expand Down Expand Up @@ -70,6 +72,11 @@ <h1>Best of NCS - No Copyright Sounds</h1>
<span class="songName">Let me Love You</span>
<span class="songlistplay"><span class="timestamp">05:34 <i id="9" class="far songItemPlay fa-play-circle"></i> </span></span>
</div>
<div class="songItem">
<img alt="1">
<span class="songName">Let me Love You</span>
<span class="songlistplay"><span class="timestamp">05:34 <i id="10" class="far songItemPlay fa-play-circle"></i> </span></span>
</div>
</div>
</div>
<div class="songBanner"></div>
Expand All @@ -82,9 +89,13 @@ <h1>Best of NCS - No Copyright Sounds</h1>
<i class="fas fa-3x fa-step-backward" id="previous"></i>
<i class="far fa-3x fa-play-circle" id="masterPlay"></i>
<i class="fas fa-3x fa-step-forward" id="next"></i>
<i class="fas fa-3x fa-sync" id="loop"></i>
<i class="fas fa-3x fa-volume-off" id="mute"></i>
</div>
<div class="songInfo">
<img src="playing.gif" width="42px" alt="" id="gif"> <span id="masterSongName">Warriyo - Mortals [NCS Release]</span>
<br>
<span class="songinfo"></span>
</div>
</div>
<script src="script.js"></script>
Expand Down
53 changes: 52 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ let masterPlay = document.getElementById('masterPlay');
let myProgressBar = document.getElementById('myProgressBar');
let gif = document.getElementById('gif');
let masterSongName = document.getElementById('masterSongName');
let isLooping = false;
let isMuted=false;
let songItems = Array.from(document.getElementsByClassName('songItem'));

let songs = [
Expand All @@ -20,6 +22,7 @@ let songs = [
{songName: "Bhula Dena - Salam-e-Ishq", filePath: "songs/2.mp3", coverPath: "covers/8.jpg"},
{songName: "Tumhari Kasam - Salam-e-Ishq", filePath: "songs/2.mp3", coverPath: "covers/9.jpg"},
{songName: "Na Jaana - Salam-e-Ishq", filePath: "songs/4.mp3", coverPath: "covers/10.jpg"},
{songName: "Neffex Best Of ME", filePath: "songs/11.mp3", coverPath: "covers/11.jpg"},
]

songItems.forEach((element, i)=>{
Expand Down Expand Up @@ -48,18 +51,54 @@ audioElement.addEventListener('timeupdate', ()=>{
// Update Seekbar
progress = parseInt((audioElement.currentTime/audioElement.duration)* 100);
myProgressBar.value = progress;
updateTimestamp();
})

myProgressBar.addEventListener('change', ()=>{
audioElement.currentTime = myProgressBar.value * audioElement.duration/100;
})
//for muting one song
function mute(){
if (!isMuted) {
audioElement.muted = true;
document.getElementById('mute').classList.remove('volume-off');
} else {
audioElement.muted = false;
document.getElementById('mute').classList.add('volume-high');
}
isMuted = !isMuted;
}
//for the looping one song
function loop(){
if (!isLooping) {
audioElement.loop = true;
// document.getElementById(gif.)
document.getElementById('loop').classList.add('fa-beat');
} else {
audioElement.loop = false;
document.getElementById('loop').classList.remove('fa-beat');
}
isLooping = !isLooping;
}

const makeAllPlays = ()=>{
Array.from(document.getElementsByClassName('songItemPlay')).forEach((element)=>{
element.classList.remove('fa-pause-circle');
element.classList.add('fa-play-circle');
})
}
//function to format time in minutes and seconds
function formatTime(seconds) {
let minutes = Math.floor(seconds / 60);
let remainingSeconds = Math.floor(seconds % 60);
return `${minutes}:${remainingSeconds < 10 ? '0' : ''}${remainingSeconds}`;
}
//handle time update event
function updateTimestamp() {
const currentTimestamp = formatTime(audioElement.currentTime);
const totalTimestamp = formatTime(audioElement.duration);
document.querySelector('.songinfo').innerText = `${currentTimestamp} / ${totalTimestamp}`;
}

Array.from(document.getElementsByClassName('songItemPlay')).forEach((element)=>{
element.addEventListener('click', (e)=>{
Expand All @@ -76,14 +115,20 @@ Array.from(document.getElementsByClassName('songItemPlay')).forEach((element)=>{
masterPlay.classList.add('fa-pause-circle');
})
})

document.getElementById('loop').addEventListener('click', () => {
loop();
});
document.getElementById('mute').addEventListener('click', () => {
mute();
});
document.getElementById('next').addEventListener('click', ()=>{
if(songIndex>=9){
songIndex = 0
}
else{
songIndex += 1;
}
makeAllPlays();
audioElement.src = `songs/${songIndex+1}.mp3`;
masterSongName.innerText = songs[songIndex].songName;
audioElement.currentTime = 0;
Expand All @@ -92,6 +137,11 @@ document.getElementById('next').addEventListener('click', ()=>{
masterPlay.classList.add('fa-pause-circle');

})
document.addEventListener('keydown',(Event)=>{
if(Event.code==="KeyM"){
mute();
}
});

document.getElementById('previous').addEventListener('click', ()=>{
if(songIndex<=0){
Expand All @@ -100,6 +150,7 @@ document.getElementById('previous').addEventListener('click', ()=>{
else{
songIndex -= 1;
}
makeAllPlays();
audioElement.src = `songs/${songIndex+1}.mp3`;
masterSongName.innerText = songs[songIndex].songName;
audioElement.currentTime = 0;
Expand Down
Binary file added songs/11.mp3
Binary file not shown.
11 changes: 11 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ nav ul li{

.icons{
margin-top: 14px;
display: flex;
justify-content: space-between;
align-items: center;
}
.icons i{
cursor: pointer;
Expand Down Expand Up @@ -109,6 +112,14 @@ nav ul li{
left: 10vw;
font-family: 'Varela Round', sans-serif;
}
#loop{
margin-left: 70%;
color: white;
}
#mute{
color: white;;
margin-left: 80%;
}

.songInfo img{
opacity: 0;
Expand Down