cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <script id="player-template" type="text/x-handlebars-template">
  <article class="player">
    <section class="main-interface animated fadeIn">
      <img class="album-artwork" src="{{track.album_artwork}}" alt="{{track.artist}} {{track.album}} Album Artwork" />
      <div class="track-details">
        <div class="track-name">{{track.title}}</div>
        <div><span class="artist-name">{{track.artist}}</span><span class="album-name"> &mdash; {{track.album}}</span></div>
      </div>
      <section class="player-controls">
        <a href="#"><i class="ion-android-list icon-playlist"></i></a>
        <a href="#"><i class="ion-ios-rewind"></i></a>
        <a href="#"><i class="ion-play"></i></a>
        <a href="#"><i class="ion-ios-fastforward"></i></a>
        <a href="#"><i class="ion-heart icon-favorite-track"></i></a>
      </section>
      <section class="track-time">
        <div class="elapsed-time">00:36</div>
        <section class="scrubber">
          <div class="scrubber-progress"></div>
        </section>
        <div class="total-time">{{track.time}}</div>
      </section>
    </section>
    <aside class="genre-sidebar">
        <div class="player-label genre-list-label">Playlists</div>
        <ul class="genre-list">
          <li class="genre-item"><a href="#" class="genre-label"><i class="ion-volume-medium"></i> Electronic</a></li>
          <li class="genre-item"><a href="#" class="genre-label">Indie</a></li>
          <li class="genre-item"><a href="#" class="genre-label">Rock</a></li>
          <li class="genre-item"><a href="#" class="genre-label">Folk</a></li>
          <li class="genre-item"><a href="#" class="genre-label">Metal</a></li>
        </ul>
    </aside>
    <aside class="playlist-sidebar">
      <div class="playlist-item">
        <span class="playlist-item-details">
          <strong>{{track.title}}</strong><br>
          {{track.artist}} &mdash; {{track.album}}
        </span>
        <span class="playlist-item-time">{{track.time}}</span>
      </div>
       <div class="playlist-item">
        <span class="playlist-item-details">
          <strong>{{track.title}}</strong><br>
          {{track.artist}} &mdash; {{track.album}}
        </span>
        <span class="playlist-item-time">{{track.time}}</span>
      </div>
       <div class="playlist-item">
        <span class="playlist-item-details">
          <strong>{{track.title}}</strong><br>
          {{track.artist}} &mdash; {{track.album}}
        </span>
        <span class="playlist-item-time">{{track.time}}</span>
      </div>
       <div class="playlist-item">
        <span class="playlist-item-details">
          <strong>{{track.title}}</strong><br>
          {{track.artist}} &mdash; {{track.album}}
        </span>
        <span class="playlist-item-time">{{track.time}}</span>
      </div>
       <div class="playlist-item">
        <span class="playlist-item-details">
          <strong>{{track.title}}</strong><br>
          {{track.artist}} &mdash; {{track.album}}
        </span>
        <span class="playlist-item-time">{{track.time}}</span>
      </div>
       <div class="playlist-item">
        <span class="playlist-item-details">
          <strong>{{track.title}}</strong><br>
          {{track.artist}} &mdash; {{track.album}}
        </span>
        <span class="playlist-item-time">{{track.time}}</span>
      </div>
    </aside>
  </article>
</script>

<body>
  <section class="player-wrapper">
  </section>
  <p class="player-note">Prototype for the Daily UI #009 prompt, a Music Player, and an experiment in using handlebars.js templating. Try re-sizing the browser for some adaptive layout fun.</p>
</body>
            
          
!
            
              @font-family-sans: 'Source Sans Pro', sans-serif; // <link> from google fonts in <head></head>
@gray-label: #a9b6bd;

// Base Layout & Typography Setup

html {
  margin: 0;
  padding: 0;
  font-weight: 400;
  line-height: 1.5;
  font-size: 16px;
}

body {
  font-family: @font-family-sans;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
  background-color: lighten(@silver,10%);
}

h1, h2, h3, h4, h5, h6, p, ul, ol {
  margin-top: 0;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 400;
  margin-bottom: 0.5rem;
  line-height: 1.15;
}

p, ul, li {
  margin-bottom: 1rem;
	font-weight: 400;
}

a {
	color: @blue;
	font-weight: 500;
  transition: all 200ms ease;
	&:hover,
  &:focus {
		color: darken(@blue, 20%);
		text-decoration: underline;
	}
}

img {
  max-width: 100%;
}

// Helper Classes

.hide {
  display:none;
}

// Re-usable Components

.player-label {
  color: @gray-label;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06rem;
}

// Layout Specific CSS

.player-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.player-note {
  color: fadeout(@black,80%);
  font-weight: 400;
  max-width: 28rem;
  text-align: center;
  margin: 1rem auto;
}

// Player CSS

.player {
  color: @black;
  background-color: @white;
  margin: 2rem;
  box-shadow: 0 19px 38px rgba(0,0,0,0.18), 
              0 15px 12px rgba(0,0,0,0.08);
  border-radius: .2rem;
  display: flex;
}

.main-interface {
  order: 2;
  width: 14rem;
  padding: 1rem;
}

.album-name,
.artist-name {
  font-size: .8rem;
}

.track-details {
  text-align: center;
  margin-top: .4rem;
  line-height: 1.1rem;
}

.track-name {
  font-weight: 600;
  font-size: 1rem;
}

.artist-name,
.album-name {
  color: @gray-label;
}

.player-controls {
  display: flex;
  justify-content: space-between;
  margin: .6rem 0;
  font-size: 1.1rem;
  i {
    padding: .4rem;
  }
}

.icon-player-control {
  color: @blue;
  transition: all 200ms ease;
}

.icon-playlist {
  color: @gray-label;
  transition: all 200ms ease;
  &:hover {
    color: darken(@gray-label,20%);
  }
}

.icon-favorite-track {
  color: darken(@red,10%);
  &:hover {
    color: darken(@red,20%);
  }
}

.track-time {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.elapsed-time,
.total-time {
  color: @gray-label;
  font-size: .8rem;
  position: relative;
}

.scrubber {
  flex: 1;
  margin: .12rem .6rem 0;
  display: block;
  border-radius: .4rem;
  height: .4rem;
  box-shadow: inset 0px 0px 1px 0px darken(@gray-label,10%),
              inset 0px 0px 1px 12px fadeout(@gray-label,90%);
}

@keyframes track-progress {
  0%   { width: 2%; }
  99% { width: 100%; }
  100% { width: 2%; }
}

.scrubber-progress {
  background-color: @orange;
  height: .4rem;
  width: 12.5%;
  border-top-left-radius: .4rem;
  border-bottom-left-radius: .4rem;
  box-shadow: inset 0px 0px 1px 0px darken(@orange,20%);
  animation: track-progress 8s infinite;
  animation-timing-function: linear;
}

.genre-sidebar {
  width: 10rem;
  order: 1;
  padding: 1rem 0;
  border-right: 1px solid lighten(@gray-label,24%);
  overflow: hidden;
  transition: width 200ms ease;
  @media (max-width: 44rem) {
    padding-left: 0;
    width: 0;
    border: 0;
  }
}

.genre-list {
  list-style: none;
  margin: 0;
  padding: 0 1rem;
}

.genre-list-label {
  .player-label();
  margin-left: 1rem;
}

.genre-item {
  margin: .4rem 0;
  white-space: nowrap;
  &:first-child {
    margin-top: 0.2rem;
    .genre-label {
      background-color: @orange;
      color: @white;
    }
  }
  &:nth-child(2) {
    .genre-label {
      background-color: @purple;
      color: @white; 
    }
  }
  &:nth-child(3) {
    .genre-label {
      background-color: @green;
      color: @white;
    }
  }
  &:nth-child(4) {
    .genre-label {
      background-color: @aqua;
      color: @white; 
    }
  }
  &:nth-child(5) {
    .genre-label {
      background-color: @maroon;
      color: @white; 
    }
  }
}

.genre-label {
  text-decoration: none;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06rem;
  padding: .3rem .6rem;
  color: @blue;
  border-radius: .3rem;
  margin: 0;
  transition: all 200ms ease;
  &:hover,
  &:focus,
  &:active {
    color: @white !important;
    background-color: @blue !important;
    border-color: @blue !important;
    text-decoration:none;
  }
}

.playlist-sidebar {
  display: flex;
  width: 14rem;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  align-items: center;
  order: 3;
  border-left: 1px solid lighten(@gray-label,24%);
  transition: width 200ms ease;
  padding: 1rem 0;
  @media (max-width: 34rem) {
    width: 0;
    border: 0;
    display: none;
  }
}

.playlist-item {
  cursor: pointer;
  display: flex;
  padding: 0 1rem;
  font-size: .8rem;
  line-height: 1.1rem;
  transition: all 200ms ease;
  &:last-child {
    border-bottom: 0;
  }
  &:hover {
    color: @blue;
  }
  @media (max-width: 34rem) {
    width: 0;
    padding: 0;
    display: none;
  }
}

.playlist-item-details {
  margin-right: 4rem;
}

.playlist-item-time {
  color: @gray-label;
  text-align: right;
}
            
          
!
            
              // TODO:
// - Fix the drawer open/close animation for the music list; there's no easing, it's just a simple toggle right now.
// - Create a JSON array of different tracks and set up the track list as a for each.
// - Add simple onboarding prompts, ex: Select a genre to play, etc.
// - How do I use this? Add controls to show/hide the playlist.
// - How do I find tracks I've loved? Add a favorites playlist.
// - Set up a counter for the time elapsed.

var source = $("#player-template").html();
var template = Handlebars.compile(source);

var track_data = {
  "track": {
    "title": "Osaka Line Loop",
    "artist": "Discovery",
    "time": "04:01",
    "album": "LP",
    "album_artwork": "https://s3-us-west-2.amazonaws.com/s.cdpn.io/27480/discovery-album-cover.jpg"
  }
}

$('.player-wrapper').append(template(track_data));

$('.icon-playlist').click(function() {
  $('.genre-sidebar').toggle();
});
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console