css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <div class="component__player">
  <div class="player__image">
  <div class="component__progress-bar">
    <div class="progress"></div>
    <span class="time-progressed"></span>
    <span class="time-total"></span>
  <div class="player__info">
	<div class="player__controls">
    <div id="btn-play-pause">
      <i class="material-icons">play_circle_filled</i>
    <div class="player__heading">
              /* VARIABLES */
$light-gray: #D1D4D5
$dark-gray: #86878E
$brand-pink: #F36A90
$brand-purple: #3A3543
/* STYLES */
  background-color: $light-gray
  font-family: 'Roboto Condensed', sans-serif
  font-weight: 300
  font-size: 13px
  color: lighten($light-gray, 2%)

h1, h3
  margin: 0
  padding: 0
  font-weight: 400

  color: $dark-gray

  color: $light-gray

  color: $light-gray
  border-radius: 50%
  padding: 5px
  display: inline-block
  text-align: center
  cursor: pointer

  color: $dark-gray
  font-size: 11px
  margin: 10px 5px
  float: left
  float: right
  background: $light-gray
  width: 100%
  height: 4px
    background: $brand-pink
    position: absolute
    height: 4px
    width: 0%
    max-width: 100%
  border-radius: 10px
  width: 400px
  background: #fff
  margin: 2% auto
  overflow: hidden
  position: relative
  box-shadow: darken($light-gray, 10%) 3px 0px 9px 5px
    background-size: cover
    width: 100%
    height: 250px
    padding: 35px 0 0 15px
    display: flex
    padding-left: 30px
    align-items: center
    padding-bottom: 20px
    width: 50%
    color: $brand-purple
    float: left
    width: 40px
    margin-right: 15px
    cursor: pointer
      font-size: 50px
              // song list
const PLAYER_PROGRESS = document.getElementsByClassName('time-progressed')[0];
const TOTAL_TIME = document.getElementsByClassName('time-total')[0];
const PLAYER_PROGRESS_BAR = document.getElementsByClassName('progress')[0];
const PLAYER_IMAGE = document.getElementsByClassName('player__image')[0];

const PLAYER_PLAY_BTN = document.getElementById('btn-play-pause');
const PLAYER_ICON = PLAYER_PLAY_BTN.getElementsByClassName('material-icons')[0];

const PLAYER_HEADING = document.getElementsByClassName('player__heading')[0];
const PLAYER_SONG_NAME = PLAYER_HEADING.getElementsByTagName('h1')[0];
const PLAYER_ARTIST_NAME = PLAYER_HEADING.getElementsByTagName('h3')[0];

// ugh need to find reliable links
let playlist = [
		"src": "http://www.stephaniequinn.com/Music/Commercial%20DEMO%20-%2010.mp3",
		"artist": "Blink-182",
		"song": "I Miss You",
		"cover": "https://usercontent1.hubstatic.com/13333864_f520.jpg"
	}, {
		"src": "http://www.stephaniequinn.com/Music/Canon.mp3",
		"artist": "Enter Shikari",
		"song": "Mothership",
		"cover": "http://www.kartinki.me/mini/201212/9718.jpg"
	}, {
		"src": "http://www.stephaniequinn.com/Music/Canon.mp3",
		"artist": "Enter Shikari",
		"song": "Adieu",
		"cover": "http://www.weedist.com/wp-content/uploads/2015/03/Great-Music-While-High-Enter-Shikari-Weedist1-640x426.jpg"

// initial
index = 0;
const TRACKS = playlist.length;
PLAYER_PROGRESS.innerHTML = '00:00';

playCurrentSong = (trackNumber) => {
	songOne = new Audio(playlist[trackNumber].src);
	PLAYER_SONG_NAME.innerHTML = playlist[trackNumber].song;
	PLAYER_ARTIST_NAME.innerHTML = playlist[trackNumber].artist;
	PLAYER_IMAGE.style.backgroundImage = 'url(' + playlist[trackNumber].cover + ')';


// grab values once metadata is loaded
songOne.addEventListener('loadedmetadata', () => {
	songDuration = parseInt(songOne.duration);
	songDurationFormatted = formatSecondsAsTime(songOne.duration);
	songTime = '0' + (songDuration / 60).toString();
	TOTAL_TIME.innerHTML = songDurationFormatted;

// update progress bar + time elapsed as song plays
songOne.addEventListener('timeupdate', () => {
	timeProgressed = (songOne.currentTime / songDuration) * 100;
	PLAYER_PROGRESS_BAR.style.width = timeProgressed + '%';
	songTime = parseInt(songOne.currentTime);
	PLAYER_PROGRESS.innerHTML = formatSecondsAsTime(songOne.currentTime);

songOne.addEventListener('ended', () => {
	PLAYER_PLAY_BTN_ICON.innerHTML = 'play_circle_filled';

// play/pause button functionality
PLAYER_PLAY_BTN.addEventListener('click', (e) => {
	if (songOne.paused) {
		PLAYER_ICON.innerHTML = 'pause_circle_filled';
	} else {
		PLAYER_ICON.innerHTML = 'play_circle_filled';

// format time from seconds
var formatSecondsAsTime = (secs) => {
  var min = Math.floor(secs / 60);
  var sec = Math.floor(secs - (min * 60));

  if (min < 10) {
    min = "0" + min;
  if (sec < 10) {
    sec = "0" + sec;
  return min + ':' + sec;
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................