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

Submitting Royalty Free Music Player Solution #46

Open
wants to merge 5 commits 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
Binary file not shown.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# assignment_royalty_free_music_player
Ushering in the reign of Royalty Free Music w/ JavaScript.

Thomas Hauge
Binary file added assets/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file added assets/audio/track1.mp3
Binary file not shown.
Binary file added assets/audio/track2.mp3
Binary file not shown.
Binary file added assets/audio/track3.mp3
Binary file not shown.
Binary file added assets/audio/track4.mp3
Binary file not shown.
Binary file added assets/audio/track5.mp3
Binary file not shown.
Binary file added assets/fonts/glyphicons-halflings-regular.eot
Binary file not shown.
288 changes: 288 additions & 0 deletions assets/fonts/glyphicons-halflings-regular.svg
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 assets/fonts/glyphicons-halflings-regular.ttf
Binary file not shown.
Binary file added assets/fonts/glyphicons-halflings-regular.woff
Binary file not shown.
Binary file added assets/fonts/glyphicons-halflings-regular.woff2
Binary file not shown.
87 changes: 87 additions & 0 deletions assets/js/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
$(document).ready(function() {

$("audio").trigger("load");

$(".play-pause").on("click", function() {
let $target = $(this);
let $audio = $target.parent().next("audio");
loadTrack($target);

if ($target.hasClass("active") && $target.hasClass("glyphicon-play")) {
$target.removeClass("glyphicon-play").addClass("glyphicon-pause");
$(".footer-play-pause").removeClass("glyphicon-play").addClass("glyphicon-pause");
$audio.trigger("play");
} else if ($target.hasClass("active") && $target.hasClass("glyphicon-pause")) {
$target.removeClass("glyphicon-pause").addClass("glyphicon-play");
$(".footer-play-pause").removeClass("glyphicon-pause").addClass("glyphicon-play");
$audio.trigger("pause");
} else {
toggleOtherTrack($target, $audio);
};
});

$(".footer-play-pause").on("click", function() {
let $target = $(this);
let $audio = $(".active").parent().next("audio");

if ($target.hasClass("glyphicon-play")) {
$target.removeClass("glyphicon-play").addClass("glyphicon-pause");
$(".active").removeClass("glyphicon-play").addClass("glyphicon-pause");
$audio.trigger("play");
} else {
$target.removeClass("glyphicon-pause").addClass("glyphicon-play");
$(".active").removeClass("glyphicon-pause").addClass("glyphicon-play");
$audio.trigger("pause");
};
});

$(".footer-previous").on("click", function() {
let $currentIndex = $(".play-pause").index($(".active"));
let $target;
let $audio;

if ($currentIndex === 0) {
$target = $(".play-pause").last();
$audio = $target.parent().next("audio");
} else {
$target = ($(".play-pause").eq($currentIndex - 1));
$audio = $target.parent().next("audio");
};

toggleOtherTrack($target, $audio);
});

$(".footer-next").on("click", function() {
let $currentIndex = $(".play-pause").index($(".active"));
let $target;
let $audio;

if ($currentIndex === $(".play-pause").length - 1) {
$target = $(".play-pause").first();
$audio = $target.parent().next("audio");
} else {
$target = ($(".play-pause").eq($currentIndex + 1));
$audio = $target.parent().next("audio");
};

toggleOtherTrack($target, $audio);
});

loadTrack = function($target) {
let title = $target.parent().parent().next().find(".track-title").text();
let artist = $target.parent().parent().next().find(".artist").text();

$(".track-selected").text(title);
$(".artist-selected").text(artist);
};

toggleOtherTrack = function($target, $audio) {
$(".play-pause").removeClass("active").removeClass("glyphicon-pause").addClass("glyphicon-play");
$("audio").trigger("pause").prop("currentTime", 0);
$target.addClass("active").removeClass("glyphicon-play").addClass("glyphicon-pause");
loadTrack($target);
$(".footer-play-pause").removeClass("glyphicon-play").addClass("glyphicon-pause");
$audio.trigger("play");
};

});
Binary file not shown.
18 changes: 18 additions & 0 deletions assets/styles/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions assets/styles/style.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions assets/styles/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.col-sm-12 {
border-bottom: 1px solid #bababa;
padding-top: 7px;
padding-bottom: 7px;
}

.faded {
font-weight: 200;
}

footer {
color: white;
.glyphicon {
color: white;
}
.btn-xlg {
border: 1px solid white;
border-radius: 50%;
background-color: inherit;
}
}
150 changes: 150 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Royalty Free Music Player</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="./assets/styles/style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="./assets/js/script.js"></script>
</head>
<body>
<header>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<span class="glyphicon glyphicon-music"></span>
</a>
<a class="navbar-brand" href="#">Royalty Free Music Player</a>
</div>
</div>
</nav>
</header>

<main>
<div class="container-fluid">

<div class="row">
<div class="col-sm-12">
<div class="media">
<div class="media-left">
<button type="button" class="btn btn-link">
<span class="glyphicon glyphicon-play play-pause active"></span>
</button>
<audio preload="none">
<source src="./assets/audio/track1.mp3" type="audio/mpeg">
</audio>
</div>
<div class="media-body">
<h4 class="media-heading track-title">Subzero</h4>
<span class="artist faded">Ben Klock</span>
</div>
</div>
</div>
</div>

<div class="row">
<div class="col-sm-12">
<div class="media">
<div class="media-left">
<button type="button" class="btn btn-link">
<span class="glyphicon glyphicon-play play-pause"></span>
</button>
<audio preload="none">
<source src="./assets/audio/track2.mp3" type="audio/mpeg">
</audio>
</div>
<div class="media-body">
<h4 class="media-heading track-title">Higher Level (Bicep Remix)</h4>
<span class="artist faded">Isaac Tichauer</span>
</div>
</div>
</div>
</div>

<div class="row">
<div class="col-sm-12">
<div class="media">
<div class="media-left">
<button type="button" class="btn btn-link">
<span class="glyphicon glyphicon-play play-pause"></span>
</button>
<audio preload="none">
<source src="./assets/audio/track3.mp3" type="audio/mpeg">
</audio>
</div>
<div class="media-body">
<h4 class="media-heading track-title">Sometimes (Original Mix)</h4>
<span class="artist faded">Detroit Swindle</span>
</div>
</div>
</div>
</div>

<div class="row">
<div class="col-sm-12">
<div class="media">
<div class="media-left">
<button type="button" class="btn btn-link">
<span class="glyphicon glyphicon-play play-pause"></span>
</button>
<audio preload="none">
<source src="./assets/audio/track4.mp3" type="audio/mpeg">
</audio>
</div>
<div class="media-body">
<h4 class="media-heading track-title">B.F.O.D.A.A.S</h4>
<span class="artist faded">Mall Grab</span>
</div>
</div>
</div>
</div>

<div class="row">
<div class="col-sm-12">
<div class="media">
<div class="media-left">
<button type="button" class="btn btn-link">
<span class="glyphicon glyphicon-play play-pause"></span>
</button>
<audio preload="none">
<source src="./assets/audio/track5.mp3" type="audio/mpeg">
</audio>
</div>
<div class="media-body">
<h4 class="media-heading track-title">German Winter (Original Mix)</h4>
<span class="artist faded">andhim</span>
</div>
</div>
</div>
</div>

</div>
</main>

<footer>
<nav class="navbar navbar-inverse navbar-fixed-bottom">
<div class="container-fluid">
<div class="navbar-header navbar-left">
<button type="button" class="btn btn-lg btn-link navbar-btn">
<span class="glyphicon glyphicon-step-backward footer-previous"></span>
</button>
<button type="button" class="btn btn-lg btn-xlg navbar-btn">
<span class="glyphicon glyphicon-play footer-play-pause"></span>
</button>
<button type="button" class="btn btn-lg btn-link navbar-btn">
<span class="glyphicon glyphicon-step-forward footer-next"></span>
</button>
<div class="navbar-right">
<h3 class="track-selected">Subzero</h3>
<span class="artist-selected faded">Ben Klock</span>
</div>
</div>
</div>
</nav>
</footer>
</body>
</html>