Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Music Player Complete #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# assignment_royalty_free_music_player
Ushering in the reign of Royalty Free Music w/ JavaScript.
Royalty Free Music Player built with JavaScript and jQuery.
Preview: https://sarahschoonmaker.github.io/assignment_royalty_free_music_player/
Binary file added audio/Dead_Moon7.mp3
Binary file not shown.
Binary file added audio/Fred_and_Toody8.mp3
Binary file not shown.
Binary file added audio/Pierced_Arrows9.mp3
Binary file not shown.
Binary file added audio/Scott_Holmes13.mp3
Binary file not shown.
Binary file added audio/Scott_Holmes3.mp3
Binary file not shown.
Binary file added images/crown.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/forward.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/pause.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/play_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/reverse.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 86 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<!DOCTYPE html>
<html>
<head>
<title>Sarah's Royalty Free Music Player</title>
<meta charset="UTF-9">
<meta name="viewport" content="width= device-width initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="js/script.js"> </script>
</head>
<!-- Header -->
<body>
<header id="header">
<img id="logo" src="images/crown.jpg">
<h1>Royalty Free Music Player</h1>
</header>
<!-- Main music section -->
<main id="main">
<section>
<div class="playBox">
<img class="play" src="images/play_button.png">
</div>
<div class="trackInfo">
<h2>Entrepreneurs</h2>
<p>Scott Holmes</p>
</div>
<audio src="audio/Scott_Holmes13.mp3"></audio>
</section>
<section>
<div class="playBox">
<img class="play" src="images/play_button.png">
</div>
<div class="trackInfo">
<h2>40 Miles of Bad Road</h2>
<p>Dead Moon</p>
</div>
<audio src="audio/Dead_Moon7.mp3"></audio>
</section>
<section>
<div class="playBox">
<img class="play" src="images/play_button.png">
</div>
<div class="trackInfo">
<h2>Last Train</h2>
<p>Fred and Toody</p>
</div>
<audio src="audio/Fred_and_Toody8.mp3"></audio>
</section>
<section>
<div class="playBox">
<img class="play" src="images/play_button.png">
</div>
<div class="trackInfo">
<h2>Let It Rain</h2>
<p>Pierced Arrows</p>
</div>
<audio src="audio/Pierced_Arrows9.mp3"></audio>
</section>
<section>
<div class="playBox">
<img class="play" src="images/play_button.png">
</div>
<div class="trackInfo">
<h2>Inspiring Corporate</h2>
<p>Scott Holmes</p>
</div>
<audio src="audio/Scott_Holmes3.mp3"></audio>
</section>
</main>
<!-- Footer -->
<footer id="footer">
<div id="controls">
<img id="prev" src="images/reverse.jpg">
<img id="playPause" src="images/play_button.png">
<img id="next" src="images/forward.jpg">
<div class="trackInfo-footer">
<h2 id="currentSong">Song</h2>
<p id="currentArtist">Artist</p>
</div>
</div>

<audio id="currentMusic" src=""></audio>
</footer>
</body>
</html>
98 changes: 98 additions & 0 deletions js/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
$(document).ready(function() {

let songIndex = 0;

//listens for click on each song's play/pause button
$(".play").each((idx, el) => {
$(el).on("click", () => {
if ($(el).attr("src") === "images/play_button.png") {
for (i = 1; i <= 5; i++) {
$("img").eq(i).attr("src", "images/play_button.png");
$("h2").eq(i - 1).removeClass("current");
}
$(el).attr("src", "images/pause.jpg");
$("#playPause").attr("src", "images/pause.jpg");
let newSong = $("audio").eq(idx).attr("src");
songIndex = idx;
if ($("#currentMusic").attr("src") !== newSong) {
$("#currentMusic").attr("src", newSong);
}
$("h2").eq(idx).addClass("current");
$("audio").get(5).play();
let songName = $("h2").eq(idx).text();
let artistName = $("p").eq(idx).text();
$("h2").eq(5).text(songName);
$("p").eq(5).text(artistName);
} else {
$(el).attr("src", "images/play_button.png");
$("#playPause").attr("src", "images/play_button.png");
$("h2").eq(idx).removeClass("current");
$("audio").get(5).pause();
}
})
})

//listens for click on the footer play/pause button
$("#playPause").on("click", () => {
if ($("#playPause").attr("src") === "images/play_button.png") {
$("#playPause").attr("src", "images/pause.jpg");
$(".play").eq(songIndex).attr("src", "images/pause.jpg");
$("h2").eq(songIndex).addClass("current");
$("audio").get(5).play();
} else {
$("#playPause").attr("src", "images/play_button.png");
$(".play").eq(songIndex).attr("src", "images/play_button.png");
$("h2").eq(songIndex).removeClass("current");
$("audio").get(5).pause();
}
});

//listens for click on previous button
$("#prev").on("click", () => {
for (i = 1; i <= 5; i++) {
$("img").eq(i).attr("src", "images/play_button.png");
$("h2").eq(i - 1).removeClass("current");
}
if ($("#playPause").attr("src") === "images/pause.jpg") {
if (songIndex !== 0) {
songIndex = songIndex - 1;
} else {
songIndex = 4;
}
let newSong = $("audio").eq(songIndex).attr("src");
$("#currentMusic").attr("src", newSong);
$("audio").get(5).play();
$(".play").eq(songIndex).attr("src", "images/pause.jpg");
$("h2").eq(songIndex).addClass("current");
let songName = $("h2").eq(songIndex).text();
let artistName = $("p").eq(songIndex).text();
$("h2").eq(5).text(songName);
$("p").eq(5).text(artistName);
}
});

//listens for click on next button
$("#next").on("click", () => {
for (i = 1; i <= 5; i++) {
$("img").eq(i).attr("src", "images/play_button.png");
$("h2").eq(i - 1).removeClass("current");
}
if ($("#playPause").attr("src") === "images/pause.jpg") {
if (songIndex !== 4) {
songIndex = songIndex + 1;
} else {
songIndex = 0;
}
let newSong = $("audio").eq(songIndex).attr("src");
$("#currentMusic").attr("src", newSong);
$("audio").get(5).play();
$(".play").eq(songIndex).attr("src", "images/pause.jpg");
$("h2").eq(songIndex).addClass("current");
let songName = $("h2").eq(songIndex).text();
let artistName = $("p").eq(songIndex).text();
$("h2").eq(5).text(songName);
$("p").eq(5).text(artistName);
}
});

});
144 changes: 144 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
section {
border: 2px solid black;
height: 80px;
display: flex;
}
section h2 {
margin-top: 10px;
margin-bottom: 10px;
color: black;
font-weight: bold;
}
section p {
margin-top: 10px;
color: gray;
font-weight: bold;
}

section:nth-child(odd) {
background-color: #E2DED7;
}

.play {
height: 75px;
width: auto;
padding: 2px;
}

#header {
border: 5px solid black;
background: #BEB9B8;
display: flex;
align-items: flex-start;
}
#header #logo {
width: 150px;
height: auto;
margin: 10px;
}

#header h1 {
font-family: "Roboto", sans-serif;
text-align: left;
margin-left: 50px;
font-size: 50px;
}

#footer {
background-color: #201F1F;
height: auto;
display: flex;
align-items: flex-start;

}

#footer img {
height: 80px;

}

#footer h2, #footer p {
font-family: "Roboto", sans-serif;
color: white;
margin-top: 0;
}
#footer h2 {
font-size: 28px;
}
#footer p {
font-size: 20px;
}

#controls {
display: flex;
align-items: flex-start;
margin-left:5%;
margin-top:.5em;

}

.trackInfo-footer {
display: inline;
text-align: left;
margin-left: 40px;
font-size: 18px;

}

.current {
color: blue;
}

// * Responsive Design
// */


@media screen and (max-width: 1024px) {


}

@media screen and (max-width: 950px) {


}


@media screen and (max-width: 547px) {
#header h1 {
margin-top: 1.5em;
margin-right: 1em;
font-size: 22px;
}


h2 {
font-size:18px;
}

.trackInfo-footer {
padding-top:5.5em;

}

#footer {
height: 200px;


}

.trackInfo-footer {
position: absolute;
width: 100%;
padding-left:1em;

}



}

@media screen and (max-width: 480px) {
your font style goes here

}