Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!-- 
// Script info:
// - Author: Michael Mammoliti
// - Name: jAudio.js
// - Version: 0.2.1
// - js dipendencies: jQuery
// - First Release: 25 November 2015
// - Last Update: 13 November 2016
// - GitHub: https://github.com/MichaelMammoliti/jAudio.js

// Contact info
// - GitHub: https://github.com/MichaelMammoliti
// - Mail: mammoliti.michael@gmail.com
// - Twitter: @MichMammoliti

// License Info
// - Released under the MIT license.
-->

<div class='jAudio'>

	<audio></audio>

	<div class='jAudio--ui'>

		<div class='jAudio--thumb'></div>

		<div class='jAudio--status-bar'>

			<div class='jAudio--details'></div>
			<div class='jAudio--volume-bar'></div>

			<div class='jAudio--progress-bar'>
				<div class='jAudio--progress-bar-wrapper'>
					<div class='jAudio--progress-bar-played'>
						<span class='jAudio--progress-bar-pointer'></span>
					</div>
				</div>
			</div>

			<div class='jAudio--time'>
				<span class='jAudio--time-elapsed'>00:00</span>
				<span class='jAudio--time-total'>00:00</span>
			</div>

		</div>

	</div>


	<div class='jAudio--playlist'>
	</div>

	<div class='jAudio--controls'>
		<ul>
			<li><button class='jAudio--control jAudio--control-prev' data-action='prev'><span></span></button></li>
			<li><button class='jAudio--control jAudio--control-play' data-action='play'><span></span></button></li>
			<li><button class='jAudio--control jAudio--control-next' data-action='next'><span></span></button></li>
		</ul>
	</div>

</div>
              
            
!

CSS

              
                /*

// Script info:
// - Author: Michael Mammoliti
// - Name: jAudio.js
// - Version: 0.2.1
// - js dipendencies: jQuery
// - First Release: 25 November 2015
// - Last Update: 13 November 2016
// - GitHub: https://github.com/MichaelMammoliti/jAudio.js

// Contact info
// - GitHub: https://github.com/MichaelMammoliti
// - Mail: mammoliti.michael@gmail.com
// - Twitter: @MichMammoliti

// License Info
// - Released under the MIT license.

*/
	
@import url(https://fonts.googleapis.com/css?family=Open+Sans:100,400,300,600,700);html{background:#383B44}.jAudio,.jAudio *{padding:0;margin:0;box-sizing:border-box;outline:0;font-family:"Open Sans";color:#888;font-weight:100}.jAudio{display:table;overflow:hidden;background:#fff;box-shadow:0 0 5px rgba(0,0,0,.8);margin:100px auto;width:352px}.jAudio:after{content:" ";display:block;width:100%;clear:both}.jAudio--ui{position:relative;width:100%}.jAudio--status-bar{width:100%;z-index:1;position:relative;padding:100px 2rem 2rem;display:table}.jAudio--status-bar:after{content:" ";display:block;width:100%;clear:both}.jAudio--controls{width:100%;background:#fafafa;display:table}.jAudio--controls:after{content:" ";display:block;width:100%;clear:both}.jAudio--controls ul{display:table;overflow:hidden;width:100%}.jAudio--controls ul:after{content:" ";display:block;width:100%;clear:both}.jAudio--controls li{position:relative;width:33.3333%;height:5rem;line-height:5rem;float:left;list-style:none}.jAudio--control{overflow:hidden;position:absolute;top:0;left:0;width:100%;height:100%;background:0 0;border:0}.jAudio--control span{position:absolute;display:table;height:15px;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);transform:translate(-50%,-50%);overflow:hidden}.jAudio--control span:after,.jAudio--control span:before{display:block;content:" ";height:0;float:left;border-color:transparent;border-style:solid}.jAudio--control:active{background:#f5f5f5}.jAudio--control-next span:after,.jAudio--control-next span:before,.jAudio--control-play span:after,.jAudio--control-play span:before,.jAudio--control-prev span:after,.jAudio--control-prev span:before{border-top:7.5px solid transparent;border-bottom:7.5px solid transparent}.jAudio--control-prev span:after,.jAudio--control-prev span:before{border-right:15px solid #ddd;border-left:0}.jAudio--control-prev:active span:after,.jAudio--control-prev:active span:before{border-right-color:#F66!important}.jAudio--control-next span:after,.jAudio--control-next span:before{border-left:15px solid #ddd;border-right:0}.jAudio--control-next:active span:after,.jAudio--control-next:active span:before{border-left-color:#F66!important}.jAudio--control-play span:before{border-left:15px solid #ddd;border-right:0}.jAudio--control-play span:after{display:none}.jAudio--control-play.active span:before,.jAudio--control-play:active span:before{border-left-color:#F66!important}.jAudio--control-pause span:after,.jAudio--control-pause span:before{width:5px;height:15px;background:#F66;border:0}.jAudio--control-pause span:before{margin-right:5px}.jAudio--control-pause span.active:after,.jAudio--control-pause span.active:before,.jAudio--control-pause span:active:after,.jAudio--control-pause span:active:before{background:#fff;margin-right:5px}.jAudio--thumb{position:absolute;top:0;left:0;height:100%;width:100%;background-size:cover;background-position:center center}.jAudio--time{display:table;width:100%}.jAudio--time:after{content:" ";display:block;width:100%;clear:both}.jAudio--time *{width:50%;display:block;float:left;color:#fff;text-shadow:0 1px 1px #000;font-size:.9rem}.jAudio--time-elapsed{text-align:left}.jAudio--time-total{text-align:right}.jAudio--details *{color:#fff;text-shadow:0 1px 1px #000;font-size:1.2rem}.jAudio--details :first-of-type{font-weight:700}.jAudio--details p{width:100%}.jAudio--details p span{display:block}.jAudio--progress-bar{margin:1.33333rem 0}.jAudio--progress-bar-wrapper{width:100%;position:relative;background:rgba(255,255,255,.3);cursor:pointer;border-radius:10px;overflow:hidden}.jAudio--progress-bar-played{height:10px;background:#F66;position:relative;border-radius:10px}.jAudio--progress-bar-pointer{height:10px;width:10px;border-radius:50%;position:absolute;right:0;background:#fff}.jAudio--playlist{background:#fff}.jAudio--playlist-item{width:100%;padding:1.33333rem 2rem;display:table}.jAudio--playlist-item:after{content:" ";display:block;width:100%;clear:both}.jAudio--playlist-item.active{background:#f55c5c;border-bottom-color:#f55c5c}.jAudio--playlist-item.active *{color:#fff}.jAudio--playlist-item:not(.active):hover{background:#fafafa}.jAudio--playlist-item:last-of-type{border:0;margin-bottom:0}.jAudio--playlist-thumb{float:left;margin-right:.66667rem;display:table}.jAudio--playlist-thumb:after{content:" ";display:block;width:100%;clear:both}.jAudio--playlist-thumb img{height:2.4rem;width:2.4rem;border-radius:50%;float:left;margin-right:.5rem}.jAudio--playlist-meta-track-name{font-size:1rem;color:#000}.jAudio--playlist-meta-track-artist{font-size:.8rem}.jAudio--controls li button span:after,.jAudio--controls li button span:before{-webkit-transition:border-color .3s ease 0s;transition:border-color .3s ease 0s}.jAudio--thumb{-webkit-transition:all .5s ease 0s;transition:all .5s ease 0s}.jAudio--progress-bar-played{-webkit-transition:all .2s ease 0s;transition:all .2s ease 0s}.jAudio--playlist-item{-webkit-transition:all .5s ease 0s;transition:all .5s ease 0s}.jAudio--playlist-item *{-webkit-transition:all .3s ease 0s;transition:all .3s ease 0s}
              
            
!

JS

              
                // Script info:
// - Author: Michael Mammoliti
// - Name: jAudio.js
// - Version: 0.2.1
// - js dipendencies: jQuery
// - First Release: 25 November 2015
// - Last Update: 13 November 2016
// - GitHub: https://github.com/MichaelMammoliti/jAudio.js

// Contact info
// - GitHub: https://github.com/MichaelMammoliti
// - Mail: mammoliti.michael@gmail.com
// - Twitter: @MichMammoliti

// License Info
// - Released under the MIT license.

!function(t){function i(i,a){this.settings=t.extend(!0,e,a),this.$context=i,this.domAudio=this.$context.find("audio")[0],this.$domPlaylist=this.$context.find(".jAudio--playlist"),this.$domControls=this.$context.find(".jAudio--controls"),this.$domVolumeBar=this.$context.find(".jAudio--volume"),this.$domDetails=this.$context.find(".jAudio--details"),this.$domStatusBar=this.$context.find(".jAudio--status-bar"),this.$domProgressBar=this.$context.find(".jAudio--progress-bar-wrapper"),this.$domTime=this.$context.find(".jAudio--time"),this.$domElapsedTime=this.$context.find(".jAudio--time-elapsed"),this.$domTotalTime=this.$context.find(".jAudio--time-total"),this.$domThumb=this.$context.find(".jAudio--thumb"),this.currentState="pause",this.currentTrack=this.settings.defaultTrack,this.currentElapsedTime=void 0,this.timer=void 0,this.init()}var a="jAudio",e={playlist:[],defaultAlbum:void 0,defaultArtist:void 0,defaultTrack:0,autoPlay:!1,debug:!1};i.prototype={init:function(){var t=this;t.renderPlaylist(),t.preLoadTrack(),t.highlightTrack(),t.updateTotalTime(),t.events(),t.debug(),t.domAudio.volume=.05},play:function(t){var i=this;i.domAudio.play(),"play"!==i.currentState&&(clearInterval(i.timer),i.timer=setInterval(i.run.bind(i),50),i.currentState="play",t.data("action","pause"),t.removeClass("jAudio--control-play"),t.addClass("jAudio--control-pause"),t.toggleClass("active"))},pause:function(t){var i=this;i.domAudio.pause(),clearInterval(i.timer),i.currentState="pause",t.data("action","play"),t.removeClass("jAudio--control-pause"),t.addClass("jAudio--control-play"),t.toggleClass("active")},stop:function(){var t=this;t.domAudio.pause(),t.domAudio.currentTime=0,t.animateProgressBarPosition(),clearInterval(t.timer),t.updateElapsedTime(),t.currentState="stop"},prev:function(){var t,i=this;t=0===i.currentTrack?i.settings.playlist.length-1:i.currentTrack-1,i.changeTrack(t)},next:function(){var t,i=this;t=i.currentTrack===i.settings.playlist.length-1?0:i.currentTrack+1,i.changeTrack(t)},preLoadTrack:function(){var t=this,i=t.settings.defaultTrack;t.changeTrack(i),t.stop()},changeTrack:function(t){var i=this;i.currentTrack=t,i.domAudio.src=i.settings.playlist[t].file,("play"===i.currentState||i.settings.autoPlay)&&i.play(),i.highlightTrack(),i.updateThumb(),i.renderDetails()},events:function(){var i=this;i.$domControls.on("click",".jAudio--control",function(){var a=t(this),e=a.data("action");switch(e){case"prev":i.prev.call(i,a);break;case"next":i.next.call(i,a);break;case"pause":i.pause.call(i,a);break;case"stop":i.stop.call(i,a);break;case"play":i.play.call(i,a)}}),i.$domPlaylist.on("click",".jAudio--playlist-item",function(){var a=t(this),e=(a.data("track"),a.index());i.currentTrack!==e&&i.changeTrack(e)}),i.$domProgressBar.on("click",function(t){i.updateProgressBar(t),i.updateElapsedTime()}),t(i.domAudio).on("loadedmetadata",function(){i.animateProgressBarPosition.call(i),i.updateElapsedTime.call(i),i.updateTotalTime.call(i)})},getAudioSeconds:function(t){var i=this,t=t%60;return t=i.addZero(Math.floor(t),2),t=60>t?t:"00"},getAudioMinutes:function(t){var i=this,t=t/60;return t=i.addZero(Math.floor(t),2),t=60>t?t:"00"},addZero:function(t,i){for(var t=String(t);t.length<i;)t="0"+t;return t},removeZero:function(t,i){for(var t=String(t),a=0;i>a&&"0"===t[0];)t=t.substr(1,t.length),a++;return t},highlightTrack:function(){var t=this,i=t.$domPlaylist.children(),a="active";i.removeClass(a),i.eq(t.currentTrack).addClass(a)},renderDetails:function(){var t=this,i=t.settings.playlist[t.currentTrack],a=(i.file,i.thumb,i.trackName),e=i.trackArtist,r=(i.trackAlbum,"");r+="<p>",r+="<span>"+a+"</span>",r+="<span>"+e+"</span>",r+="</p>",t.$domDetails.html(r)},renderPlaylist:function(){var i=this,a="";t.each(i.settings.playlist,function(t,i){{var e=i.file,r=i.thumb,o=i.trackName,s=i.trackArtist;i.trackAlbum}trackDuration="00:00",a+="<div class='jAudio--playlist-item' data-track='"+e+"'>",a+="<div class='jAudio--playlist-thumb'><img src='"+r+"'></div>",a+="<div class='jAudio--playlist-meta'>",a+="<p class='jAudio--playlist-meta-track-name'>"+o+"</p>",a+="<p class='jAudio--playlist-meta-track-artist'>"+s+"</p>",a+="</div>",a+="</div>"}),i.$domPlaylist.html(a)},run:function(){var t=this;t.animateProgressBarPosition(),t.updateElapsedTime(),t.domAudio.ended&&t.next()},animateProgressBarPosition:function(){var t=this,i=100*t.domAudio.currentTime/t.domAudio.duration+"%",a={width:i};t.$domProgressBar.children().eq(0).css(a)},updateProgressBar:function(t){var i,a,e,r=this;t.offsetX&&(i=t.offsetX),void 0===i&&t.layerX&&(i=t.layerX),a=i/r.$domProgressBar.width(),e=r.domAudio.duration*a,r.domAudio.currentTime=e,r.animateProgressBarPosition()},updateElapsedTime:function(){var t=this,i=t.domAudio.currentTime,a=t.getAudioMinutes(i),e=t.getAudioSeconds(i),r=a+":"+e;t.$domElapsedTime.text(r)},updateTotalTime:function(){var t=this,i=t.domAudio.duration,a=t.getAudioMinutes(i),e=t.getAudioSeconds(i),r=a+":"+e;t.$domTotalTime.text(r)},updateThumb:function(){var t=this,i=t.settings.playlist[t.currentTrack].thumb,a={"background-image":"url("+i+")"};t.$domThumb.css(a)},debug:function(){var t=this;t.settings.debug&&console.log(t.settings)}},t.fn[a]=function(a){var e=function(){return new i(t(this),a)};t(this).each(e)}}(jQuery);



(function(){

  var t = {
    playlist: [
      {
        file: "http://www.michaelmammoliti.com/_projects/audioJS/songs/01.mp3",
        thumb: "http://www.michaelmammoliti.com/_projects/audioJS/artworks/01.jpg",
        trackName: "Dusk",
        trackArtist: "Tobu & Syndec",
        trackAlbum: "Single",
      },
      {
        file: "http://www.michaelmammoliti.com/_projects/audioJS/songs/02.mp3",
        thumb: "http://www.michaelmammoliti.com/_projects/audioJS/artworks/02.jpg",
        trackName: "Blank",
        trackArtist: "Disfigure",
        trackAlbum: "Single",
      },
      {
        file: "http://www.michaelmammoliti.com/_projects/audioJS/songs/03.mp3",
        thumb: "http://www.michaelmammoliti.com/_projects/audioJS/artworks/03.jpg",
        trackName: "Fade",
        trackArtist: "Alan Walker",
        trackAlbum: "Single",
      }
    ]
  }

  $(".jAudio").jAudio(t);

})();
              
            
!
999px

Console