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

              
                <html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Music Player</title>
  <link rel="stylesheet" type="text/css" href="style.css">
  <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300' rel='stylesheet' type='text/css'>
  <link rel="stylesheet" href="https://www.w3schools.com/lib/w3.css">
</head>
<body>

  <audio controls id="song">
    <source src="last_chance.mp3" type="audio/mpeg">
  </audio>

  <div id="player">
    <div id="cover"></div>

    <div class="display">
      <div id="songTitle">
        <h1 class="info">Kaskade</h1>
        <h3 class="info">Last Chance</h3>
        <p class="info">Atmosphere</h4>
      </div>
      <div id="toolBar">
        <div><i class="tool fa fa-2x fa-share-square-o" aria-hidden="true"></i></div>
        <div id="star"><i class="tool fa fa-2x fa-star" aria-hidden="true"></i></div>
        <div id="heart"><i class="tool fa fa-2x fa-heart" aria-hidden="true"></i></div>
      </div>
    </div>

    <div id="progressBar">
      <div class="w3-progress-container">
        <div id="bar" class="w3-progressbar w3-round w3-green" style="width:0%"></div>
      </div>
    </div>
    

    <div id="control">
      <div id="stop"><i class="fa fa-2x fa-stop" aria-hidden="true"></i></div>
      <div id="pause"><i class="fa fa-2x fa-pause" aria-hidden="true"></i></div>
      <div id="play"><i class="fa fa-2x fa-play" aria-hidden="true"></i></div>
      <div id="backward"><i class="fa fa-lg fa-backward" aria-hidden="true"></i></div>
      <div id="forward"><i class="fa fa-lg fa-forward" aria-hidden="true"></i></div>
      <div id="random"><i class="fa fa-random" aria-hidden="true"></i></div>
    </div>

  </div>
 
  
  <script src="https://use.fontawesome.com/b4561866ad.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
  <script type="text/javascript" src="app.js"></script>
</body>
</html>
              
            
!

CSS

              
                body{
  background-color: #f3f3f3;
  color:#484848;
  font-family: 'Open Sans', sans-serif;
}

#player{
  display: block;
  width: 530px;
  height: 550px;
  border-radius: 20px;
  background-color: white;
  box-shadow: 0 0 50px #888888;
  margin:auto;
  margin-top: 5%;
}

#song {
  display:none;
}
/* cover img*/
#cover{
  height: 33%;
  background-color: gray;
  border-radius: 20px 20px 0 0;
  background: url("https://upload.wikimedia.org/wikipedia/en/9/91/Kaskade_Atmosphere.jpg");
  background-size: cover;
}


/* info display*/
.display{
  display: flex;
  align-items: flex-start;
  margin-top: 10%;
}

.info{
  margin-left: 15%;
  margin-bottom: 0;
  margin-top: 5px;
}

.info p{
  font-weight: 300; 
}

#songTitle{
  width: 65%;
  height: 130px;
}

#toolBar{
  width: 35%;
  height: 130px;
  display: inline-flex;
}

.tool{
  color:#B8B8B8;
  margin:10px;
}


.fa-share-square-o:hover{
  color: #282828; 
}

#progressBar{
  height: 60px;
  width: 85%;
  position: relative;
  left:50%;
  transform: translateX(-50%);
  margin-top: 15px;
}


/* control panel*/
#control{
  display: flex;
  align-items: center;
  margin-left: 5%;
}


#pause, #play, #stop{
  height: 60px;
  width: 60px;
  border-radius:50px;
  background-color: #505050;
  text-align: center;
  position: relative;
  margin:10px;
}

#backward, #forward{
  height: 50px;
  width: 50px;
  border-radius: 30px;
  background-color: #505050;
  position: relative;
  margin:10px;
}

#control .fa{
  position: absolute;
  color:white;
  top:50%;
  left:50%;
  transform: translate(-50%, -50%);

}

.heart{
  color:#FF3366;
}

.star{
  color:#FFCC33;
}

              
            
!

JS

              
                $( document ).ready(function() {
    var song = document.getElementById('song');

    function playMp3(){
      song.play();
    }

    function pauseMp3(){
      song.pause();
    }


    var elem = $('#bar')[0];
    var play=false;
    var width = 0;
    var timerID;
    var speed = 0.03861;
    var fast = false;

    // click play
    $('#play').on('click',function(){
        // prevent click the second time.
        if(!play){
            var id = setInterval(frame, 100);
            timerID = id
            play = true;

            playMp3();
        }

        function frame() {
            if (width >= 100) {
                clearInterval(id);
            } else {
                if(fast){width+=0.5}
                else{width+=speed}
                elem.style.width = width + '%'; 
            }
        }
    })

    // click pause
    $('#pause').on('click', function(){
        fast = false;
        play = false;
        clearInterval(timerID);

        pauseMp3();
    })

    // click forward
    $('#forward').on('click', function(){
        $('#pause').click();
        fast = true
        play = false;
        $('#play').click();
    })

    // click stop
    $('#stop').on('click', function(){
        fast = false;
        play = false;
        clearInterval(timerID);
        elem.style.width = 0+'%'
        width=0
    })

    // click backward
    $('#backward').on('click',function(){
        $('#pause').click();
        // change bar backward : decrement width
        var id = setInterval(goBack, 50);
        timerID = id;

        function goBack(){
            if(width<=0){
                clearInterval(id);
            } else {
                width -=0.5
                elem.style.width = width + '%';
            }
        }
    })

    // add class
    $('.fa-heart').on('click',function(){
      $(this).toggleClass('heart');
    })

    $('.fa-star').on('click',function(){
      $(this).toggleClass('star');
    }) 
});

              
            
!
999px

Console