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.

            
              <html lang="en">
<head>
  <meta charset="UTF-8"/>
<link href='https://fonts.googleapis.com/css?family=Sintony:400' rel='stylesheet' type='text/css'>
  <script src='//w.soundcloud.com/player/api.js'></script>
</head>
<body>
	<div class='player'>
	  <div class='art'></div>
	  <div class='info'>
      <div class='title'></div>
      <div class='song'></div>
	    <div class='progress'>
	      <div class='progress-bar'></div>
	    </div>
	  </div>  
	  <div class='controls'>
	    <button class='play glyphicon glyphicon-play'></button>    
	    <button class='backward glyphicon glyphicon glyphicon-backward'></button>
	    <button class='forward glyphicon glyphicon-forward'></button>      
      <div class="settings glyphicon glyphicon-cog"></div>
	  </div>
	</div>
  
  <iframe class="sc-widget" src="//w.soundcloud.com/player/?url=//soundcloud.com/caribouband"></iframe>
  
</body>
</html>
            
          
!
            
              * { 
  box-sizing: border-box;
  transition: background 1s ease-in;
}
iframe { display: none; }
body{
  background: #d2d5d6;
  font-family: 'Sintony', sans-serif;
  font-size: 16px;
}
.player {
  overflow: hidden;
  position: absolute;
  top: 0; bottom: 0; left: 0; right: 0;
  margin: auto;
  height: 250px;
  width: 220px;
  
  background: #edf0f2;
  border-radius: 10px;
  box-shadow: 
    0 8px 10px 2px rgba(0,0,0,.1),
    0 30px 15px -5px rgba(0,0,0,.05);
}
.art {
  overflow: hidden;
  height: 32%;
  width: 100%;
  
  background: #DDD;
  background-image: url('');
  background-size: cover;
  background-position: center;
} 
.info {
  height: 20%;
  margin-top: 15%;  
  padding: 0 10%;
}
.info .title { 
  height: 50%;
  width: 100%;
  
  font-size: 0.9em;
  color: #48586b;
  text-shadow: 0 1px #EFEFEF;
}
.info .song {
  height: 50%;
  display: block;
  font-size: 0.6em;
  color: #6a7888;
}
.info .progress {
  user-select: none;
  cursor: pointer;
  clear: both;
  overflow: hidden;
  position: relative;
  top: 18px;
  height: 4px;
  width: 100%;
  
  background: #333;
  border-radius: 3px;
  box-shadow: 0 -1px 0 1px #DFDFDF;
}
.progress .progress-bar {
  height: 100%;
  width: 0%;
  
  background: #cdd2d7;
  border-radius: 5px;
}
.controls {
  position: relative;
  margin: 18% 0 6.5% 0; 
  padding: 0 10%;
}
.controls button {
  cursor: pointer;
  position: absolute;
  height: 27px;
  width: 27px;
  border: none;
  
  text-align: center;  
  background: #414141;
  color: #d9d9d9;
  border-radius: 50%;
  font-size: 0.8em;
  transition: .1s;
  line-height: 1em;
}
.controls button:hover {
  opacity: 0.95;
}
.controls button:active{
  opacity: 0.5;
}
.controls .play {
  height: 37px;
  width: 37px;
  
  font-size: 1.2em;
  line-height: 35px;
}
.controls .backward, .controls .forward {
  top: .7em;
  font-size: .5em;
  letter-spacing: .4em;
  line-height: .7em;
}
.controls .backward {
  left: 28%;
}
.controls .forward {
  left: 42%;  
  letter-spacing: .3em;
  text-align: right;
}

.controls .settings {
  cursor: pointer;
  color: #CCC;
  float: right;
  margin-top: 5%;
}

.controls .settings:hover { color: #AAA; }
            
          
!
            
              console.clear();
$(document).ready(function(){  

  var player  =  SC.Widget($('iframe.sc-widget')[0]);

	var pOffset = $('.progress').offset(); //Zero the progress bar
  var pWidth = $('.progress').width();
	var scrub;

  player.bind(SC.Widget.Events.READY, function(eventData) { setInfo();	}); //Set info on load
  player.bind(SC.Widget.Events.PLAY_PROGRESS, function(e) {
    if( e.relativePosition < 0.003 ) { setInfo(); }
    //Event listener when track is playing
    $('.progress-bar').css('width', ( e.relativePosition*100)+"%");

    if( !$(".play").hasClass('glyphicon-pause') ) {
      $(".play")
          .removeClass('glyphicon-play')
          .addClass('glyphicon-pause'); 
    }
  });

  player.bind(SC.Widget.Events.PAUSE, function(e) {   //Event listener when track is paused
      setInfo();
      $(".play")
        .addClass('glyphicon-play')
        .removeClass('glyphicon-pause');  
  });

  $('.progress').mousemove(function(e){ //Get position of mouse for scrubbing
    scrub = (e.pageX-pOffset.left);
  });

  $('.progress').click(function(){ //Use the position to seek when clicked
    $('.progress-bar').css('width',scrub+"px");
    var seek = player.duration*(scrub/pWidth);
    player.seekTo(seek);
  });

  //Buttons
  $('.play').click(function(){ player.toggle(); });    
  $('.backward').click(function(){ player.prev(); });  
  $('.forward').click(function(){ player.next(); });

  function setInfo() {
    player.getCurrentSound(function(song) {
      if(!song) {
        $('.art').css('background-image', '');
        $('.title').html('');
        $('.song').html('No artist found :(');
        return;
      }
      $('.art').css('background-image', "url('" + song.artwork_url.replace('-large', '-t500x500') + "')");
      $('.title').html(song.user.username);
      $('.song').html(song.title);
      player.current = song;
    });
    
    player.getDuration(function(value){
      player.duration = value;
    });


    player.isPaused(function(bool){
      player.getPaused = bool;
    });
  }

  $('.settings').click(function(){
    
    var url = prompt('Enter Soundcloud Url','https://soundcloud.com/');
    
    if (url) {
      player.pause();
      
    var option = {
      callback: function(){
        setInfo();
      }
    }
    player.load(url , option);
      
    }
        
  });
  
    
}); 
            
          
!
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