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 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.

            
              <audio id="audio">
	<source src="http://laptevpavel.ru/playground/player/Ari_Mason-Dressed_For_Space.ogg">
	<source src="http://laptevpavel.ru/playground/player/Ari_Mason-Dressed_For_Space.mp3">
</audio>

<div class="audio-player">
	<div class="cover-art">
		<a href="https://soundcloud.com/arimason" target="_blank"></a>
	</div>
	<div class="info">
		<h2>Ari Mason</h2>
		<h3>Dressed For Space <span style="color: #999999; font-size: 12px;">(<a href="https://www.youtube.com/watch?v=mjwM0eIQ6Rc" target="_blank">TR/SR</a> cvr)</span></h3>
		<p id="timeleft">00:00</p>
		<div class="progressbar_slide">
			<div class="progressbar_range"></div>
		</div>
	</div>
	<div class="controls">
		<div class="controls_plays">

			<svg id="prev_btn" viewBox="0 0 24.5 23.6">
				<polygon points="0,11.8 13.5,0 13.5,10.7 24.5,0 24.5,23.6 13.5,12.9 13.5,23.6 "/>
			</svg>

			<svg id="plays_btn" viewBox="0 0 24.5 30.9">
				<g id="play_btn">
					<path d="M0,30.9L0,0l24.5,15.4L0,30.9z"/>
				</g>
				<g id="pause_btn">
					<rect x="0" y="0" width="8.2" height="30.9"/>
					<rect x="16.2" y="0" width="8.2" height="30.9"/>
				</g>
			</svg>

			<svg id="next_btn" viewBox="0 0 24.5 23.6">
				<polygon points="25,11.8 11.5,0 11.5,10.7 0.5,0 0.5,23.6 11.5,12.9 11.5,23.6 "/>
			</svg>

		</div>
		<div class="controls_player">

			<svg id="volume_btn" viewBox="0 0 23 23">
				<path d="M17.5,6.6v9.9L11.4,13H5.5v-3h6L17.5,6.6z M10.7,7H2.5v9h8.2l9.8,5.3V1.2L10.7,7z"/>
			</svg>

			<svg id="shuffle_btn" viewBox="0 0 23 23">
				<path d="M7.3,6l0.4,2.8l3.6-5l-5-3.6l0.5,3C3.6,4.4,1.1,7.4,1.1,11c0,4.4,2.4,8,7.4,8.3v-2.7
							c-3-0.3-4.7-2.7-4.7-5.6C3.8,8.8,5.5,7,7.3,6z"/>
				<path d="M21.5,11c0-4.4-4-8-8-8.3v2.7c2,0.3,5.2,2.7,5.2,5.6c0,2.2-1.2,4-3,5l-0.4-2.8l-3.6,5l5,3.6l-0.6-3
							C19.4,17.6,21.5,14.6,21.5,11z"/>
			</svg>

			<svg id="playlist_btn" viewBox="0 0 23 23">
				<rect x="1.5" y="2" width="20" height="3"/>
				<rect x="1.5" y="9" width="20" height="3"/>
				<rect x="1.5" y="17" width="20" height="3"/>
			</svg>

		</div>
	</div>

</div>
            
          
!
            
              @import url(https://fonts.googleapis.com/css?family=Roboto:400,500,700);

$base-clr: #7fe5a3;

@mixin centerer {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

body{
    font-family: 'Roboto', sans-serif;
    background: $base-clr;
    overflow:hidden;
}

audio{
    position:absolute;
}

h2{
    font-size:26px;
	 margin: 14px 0;
    font-weight:700;
}

h3{
    font-size:16px;
    font-weight:400;
}

p{
    display: inline-block;
    font-size:14px;
    font-weight:400;
    margin-bottom:10px;
    color: grey;
}

a{
	text-decoration: none;
	color: #9d57e4;
}

.audio-player{
    @include centerer;
    display:flex;
    flex-direction: column;
    justify-content: space-around;
    transition:all 0.2s;
	 width:90vw;
    max-width:700px;
    background:white;
    box-sizing: border-box;
    @media screen and (max-width: 560px){
        width:90vw;
        background:white;
    }
}

.info{
    flex:1;
    padding: 16px 30px;
}

.cover-art{
    position:absolute;
    bottom:160px;
    right:-30px;
    width: 230px;
    height:230px;
    background: url(http://laptevpavel.ru/playground/player/drassed-for-space.jpg);
    background-size: cover;
    @media screen and (max-width: 560px){
        position:relative;
        width:100%;
        height:80vw;
        bottom:inherit;
        right:inherit;
    }
    @media screen and (max-width: 520px){
        position:relative;
        width:100%;
        height:90vw;
        bottom:inherit;
        right:inherit;
    }
    @media screen and (max-height: 500px){
        display:none;
        width: 0px;
        height: 0px;
    }
    transition: all 0.2s;
    a{
        display:block;
        width:100%;
        height:100%;
        &:hover{
            background: darken($base-clr, 30%);
            opacity:0.2;
        }
    }
}

.controls{
    display:flex;
    width:100%;
    height:100px;
    background:white;
    margin-top:-1px;
    padding:20px;
    box-sizing:border-box;
    &_plays{
        flex:2;
        display:flex;
        justify-content: space-around;
    }
    &_player{
        flex:1;
        fill: #7FE5A3;
        display:flex;
        justify-content: space-around;
    }
    @media screen and (max-width: 420px){
        flex-direction: column;
        height:200px;
    }
	transition: all 0.2s;
}

#plays_btn, #prev_btn, #next_btn{
    cursor:pointer;
    width:26px;
    max-width:18px;
    &:hover{
        fill: #565349;
    }
    transition: all 0.2s;
}

#pause_btn{
    display:none;
}

#volume_btn, #shuffle_btn, #playlist_btn{
    cursor:pointer;
    width:23px;
    max-width:18px;
    //padding:10px;
    &:hover{
        fill: darken($base-clr, 30%);
    }
    transition: all 0.2s;
}

.progressbar_slide{
    width:100%;
    background:$base-clr;
    height:6px;
}
.progressbar_range{
    width:0;
    background:black;
    height:6px;
}
            
          
!
            
              // var for audio content

var audio = document.getElementById('audio');

// html5 function - toggle play/pause btn and audio

$("#plays_btn").click(function() {

    if (audio.paused == false) {
        audio.pause();
        $("#play_btn").show();
        $("#pause_btn").hide();
    } else {
        audio.play();
        $("#play_btn").hide();
        $("#pause_btn").show();
    }
});


// function for timeline

audio.addEventListener("timeupdate", function() {
    var currentTime = audio.currentTime,
        duration = audio.duration,
        currentTimeMs = audio.currentTime * 1000;
    $('.progressbar_range').stop(true, true).animate({'width': (currentTime + .25) / duration * 100 + '%'}, 250, 'linear');
});


// count function for timeleft

audio.addEventListener("timeupdate", function() {
    var timeleft = document.getElementById('timeleft'),
        duration = parseInt( audio.duration ),
        currentTime = parseInt( audio.currentTime ),
        timeLeft = duration - currentTime,
        s, m;
    
    s = timeLeft % 60;
    m = Math.floor( timeLeft / 60 ) % 60;
    
    s = s < 10 ? "0"+s : s;
    m = m < 10 ? "0"+m : m;
    
    $('#timeleft').text("-"+m+":"+s);
    
});

//that's all folks
// sorry, others buttons dont work)
            
          
!
999px
🕑 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 ..................

Console