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

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.

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

              
                <br />
<div id="mp3Player">                       
<div id="mp3PlayerButtons">
<a onclick="bntMp3Play();"><i class="fa fa-play fa-2x" aria-hidden="true"></i></a>&nbsp;&nbsp;
<a onclick="bntMp3Pause();"><i class="fa fa-pause fa-2x" aria-hidden="true"></i></a>&nbsp;&nbsp;
<a onclick="bntMp3Stop();"><i class="fa fa-stop fa-2x" aria-hidden="true"></i></a>
</div>
<div id="mp3PlayerProgressBar">
  <div id="slider">
    <div id="currentTimeBar"></div>
  </div>
  </div>
  <div id="mp3PlayerTime">
    <b><span id="lblMp3State"></span><span id="lblMp3Lenght"></span></b>
  </div>                            
</div>
              
            
!

CSS

              
                body {
  background-color: lightgray;
}

#mp3Player {
  display: flex
}

#mp3Player a {
  color: #000;
  cursor: pointer
}

#mp3PlayerButtons {
  width: 120px;
  margin-top: -10px
}

#mp3PlayerProgressBar {
  flex: 1;
  padding: 5px;
  font-size: 18px
}

#mp3PlayerTime {
  width: 100px;
  font-size: 18px
}


/* Component containers ----------------------------------*/

.ui-widget.ui-widget-content {
  border: 1px solid #c5c5c5
}

.ui-corner-all,
.ui-corner-bottom,
.ui-corner-right,
.ui-corner-br {
  border-bottom-right-radius: 3px
}

ui-corner-all,
.ui-corner-bottom,
.ui-corner-left,
.ui-corner-bl {
  border-bottom-left-radius: 3px
}

.ui-corner-all,
.ui-corner-top,
.ui-corner-right,
.ui-corner-tr {
  border-top-right-radius: 3px
}

.ui-corner-all,
.ui-corner-top,
.ui-corner-left,
.ui-corner-tl {
  border-top-left-radius: 3px
}

.ui-widget-content {
  border: 1px solid #ddd;
  background: #fff;
  color: #333
}

.ui-widget {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1em
}

.ui-slider-horizontal {
  height: .8em
}

.ui-slider {
  position: relative;
  text-align: left
}


/*Segnaposto*/

elemento {
  left: 0
}

.ui-state-default,
.ui-widget-content .ui-state-default,
.ui-widget-header .ui-state-default,
.ui-button,
html .ui-button.ui-state-disabled:hover,
html .ui-button.ui-state-disabled:active {
  border: 1px solid #c5c5c5;
  background: #f6f6f6;
  font-weight: 400;
  color: #454545
}

.ui-slider-horizontal .ui-slider-handle {
  top: -.3em;
  margin-left: -.6em
}

.ui-slider .ui-slider-handle {
  position: absolute;
  z-index: 2;
  width: 1.2em;
  height: 1.2em;
  cursor: default;
  -ms-touch-action: none;
  touch-action: none
}

.ui-corner-all,
.ui-corner-bottom,
.ui-corner-right,
.ui-corner-br {
  border-bottom-right-radius: 3px
}

.ui-corner-all,
.ui-corner-bottom,
.ui-corner-left,
.ui-corner-bl {
  border-bottom-left-radius: 3px
}

.ui-corner-all,
.ui-corner-top,
.ui-corner-right,
.ui-corner-tr {
  border-top-right-radius: 3px
}

.ui-corner-all,
.ui-corner-top,
.ui-corner-left,
.ui-corner-tl {
  border-top-left-radius: 3px
}

.ui-widget-content {
  color: #333
}

.ui-widget {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1em
}

.ui-slider {
  text-align: left
}


/* Barra segna tempo*/

#currentTimeBar {
  position: absolute;
  width: 0;
  height: 100%;
  background-color: #5FB4E1
}
              
            
!

JS

              
                "use strict";
var keepGoing = true;

            // 0 onLoad - 1 play - 2 pause
            var playerState = 0;
            var mp3Lenght = 0;
            var currentTimeBar = document.getElementById("currentTimeBar");
            
            var sound = new Howl({
                src: ['http://www.corsoinglese.org/audio/esercizi/1.mp3']
            });

            // Carico quanto è lungo l'mp3
            sound.once('load', setTotalTime);
                    
            function setTotalTime() {
                mp3Lenght = sound._duration;
                $("#lblMp3Lenght").text(mp3Lenght + ' s');
              
                var handle = $("#custom-handle");
                // Mi va al secondo x (in base alla percentuale della barra)
                $("#slider").slider({
                        slide: function (event, ui) {
                            var goTO = Math.round((mp3Lenght / 100) * ui.value);
                            sound.seek(goTO);
                        }
                    });
            }                                  
            
            // Fires when the sound finishes playing.
            sound.on('end', function () {
                stopLoop();
            });

            // Fires when the sound start to play
            sound.on('play', function () {
                startLoop();
                playerState = 1;
                
            });    

            function myLoop() {
                // Aggiorno il tempo
                var with2Decimals = sound.seek().toString().match(/^-?\d+(?:\.\d{0,2})?/)[0];
                $("#lblMp3State").text(with2Decimals + ' / ');
                // Calcolo la percentuale di avanzamento dell'mp3
                var width = (sound.seek() * 100) / mp3Lenght;              
                currentTimeBar.style.width = width + '%';
                $("#slider").slider("value", width); // Setto il segnaposto
                if (keepGoing) {
                    setTimeout(myLoop, 250);
                }
            }           

            function startLoop() {
                keepGoing = true;
                myLoop();
            }

            function stopLoop() {
                keepGoing = false;
            }

            function bntMp3Play() {
                if (playerState == 2) {
                    sound.play();
                }
                else {
                    sound.stop().play();
                }
                playerState = 1;
            }

            function bntMp3Pause() {
                sound.pause();
                playerState = 2;
            }

            function bntMp3Stop() {
                sound.stop();
                playerState = 0;
                var with2Decimals = sound.seek().toString().match(/^-?\d+(?:\.\d{0,2})?/)[0];
                $("#lblMp3State").text(with2Decimals + ' /');
            }
              
            
!
999px

Console