Skip to content

Commit

Permalink
Music_Player
Browse files Browse the repository at this point in the history
  • Loading branch information
HUN-sp committed Jan 30, 2024
0 parents commit 0f844e5
Show file tree
Hide file tree
Showing 5 changed files with 203 additions and 0 deletions.
Binary file added Way-Down-We-Go(PaglaSongs).mp3
Binary file not shown.
47 changes: 47 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Music Player</title>
<link rel="stylesheet" href="style.css">
<script src="https://kit.fontawesome.com/713c813b50.js" crossorigin="anonymous"></script>
</head>

<body>
<div class="container">
<div class="music-player">
<nav>
<div class="circle">
<i class="fa-solid fa-angle-left"></i>
</div>
<div class="circle">
<i class="fa-solid fa-bars"></i>
</div>
</nav>
<img src="music1.jpeg" class="song-img">
<h1>Way Down We Go</h1>
<p>KALEO</p>

<audio controls id="song">
<source src="Way-Down-We-Go(PaglaSongs).mp3" type="audio/mpeg">
</audio>

<input type="range" value="0" id="progress">


<div class="controls" id="song">
<div><i class="fa-solid fa-backward"></i></div>
<div onclick="playPause()"><i class="fa-solid fa-play" id="ctrlIcon"></i></div>
<div><i class="fa-solid fa-forward"></i></div>
</div>


</div>

</div>
<script src="index.js"></script>
</body>

</html>
65 changes: 65 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// let progress=document.getElementById("progress");
// let song=document.getElementById("song");
// let ctrlIcon=document.getElementById("ctrlIcon");


// song.onloadedmetadata = function(){
// progress.max=song.duration;
// progress.value=song.currentTime;
// }

// function playPause(){
// if(ctrlIcon.classList.contains("fa-pause")){
// song.pause();
// ctrlIcon.classList.remove("fa-pause");
// ctrlIcon.classList.add("fa-play");
// }else{
// song.play();
// ctrlIcon.classList.remove("fa-play");
// ctrlIcon.classList.add("fa-pause");
// }
// }

// if(song.play()){
// setInterval(()=>{
// progress.value=song.currentTime;
// },500);
// }

// progress.onchange()=function(){
// song.play();
// song.currentTime=progress.value;
// ctrlIcon.classList.remove("fa-play");
// ctrlIcon.classList.add("fa-pause");
// }

let progress = document.getElementById("progress");
let song = document.getElementById("song");
let ctrlIcon = document.getElementById("ctrlIcon");

song.onloadedmetadata = function () {
progress.max = song.duration;
progress.value = song.currentTime;
};

function playPause() {
if (song.paused) {
song.play();
ctrlIcon.classList.remove("fa-play");
ctrlIcon.classList.add("fa-pause");
} else {
song.pause();
ctrlIcon.classList.remove("fa-pause");
ctrlIcon.classList.add("fa-play");
}
}

song.addEventListener("timeupdate", function () {
progress.value = song.currentTime;
});

progress.oninput = function () {
song.currentTime = progress.value;
};

ctrlIcon.onclick = playPause;
Binary file added music1.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
91 changes: 91 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
*{margin:0;
padding:0;
font-family:'Poppins',sans-serif;
box-sizing: border-box;
}
.container{
width : 100%;
height : 100vh;
background-color: #333;
display: flex;
align-items: center;
justify-content: center;
flex-wrap:wrap;
}
.music-player{
background:#ffe0e5;
width:400px;
padding :25px 35px;
text-align: center;
}
nav{
display: flex;
justify-content: space-between;
margin-bottom: 30px;
}
nav .circle{
border-radius: 50%;
width: 40px;
height: 40px;
line-height: 40px;
background: #fff;
color: #f53192;
box-shadow: 0px 5px 10px rgba(255 26 26 0.22);
}
.song-img{
width: 220px;
border-radius: 50%;
border: 8px solid #fff;
box-shadow: 0 10px 60px rgba(255 26 26 0.22);
}
.music-player h1{
font-size: 20px;
font-weight: 400;
color: #333;
margin-top: 20px;
}
.music-player p{
font-size: 14px;
color: #333;
}
#progress{
-webkit-appearance: none;
width: 100%;
height: 6px;
background: #f53192;
border-radius: 4px;
cursor: pointer;
margin: 40px 0;
}
#progress::-webkit-slider-thumb{
-webkit-appearance: none;
background: #f53192;
width: 30px;
height: 30px;
border-radius: 50%;
border: 8px solid #fff;
box-shadow: 0 5px 5px rgba(255 26 26 0.22);
}
.controls{
display: flex;
justify-content: center;
align-items: center;
}
.controls div{
width: 60px;
height: 60px;
margin: 20px;
background: #fff;
display: inline-flex;
align-items: center;
justify-content: center;
border-radius: 50px;
color: #f53192;
box-shadow: 0 10px 20px rgba(255 26 26 0.22);
cursor: pointer;
}
.controls div:nth-child(2){
transform: scale(1.5);
background: #f53192;
color: #fff;
}

0 comments on commit 0f844e5

Please sign in to comment.