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

              
                <h1>Responsive Music Player</h1>
<p>This is a very simplified and barebones version of the Music Player I have on my website! :)</p>
<p>Depending on your browser settings, music may or may not play automatically, but the player should sit neatly in the corner of your page and not be visually disruptive, even on smaller screens!</p>
<p>I use the song name to link to Youtube in order for people to find the source of the audio, but it's not necessary for the code to work, it's simply a formality! :)</p>
<p>Feel free to mess around with the CSS to customize the player however you like!</p>

<div class="autoplayer">
  <div class="buttondiv">
    <button id="button"><i class="fa fa-pause"></i></button>
  </div>
  <audio loop autoplay id="player">
    <source src='https://ne0nbandit.github.io/assets/music/Beat%20Street.mp3' type='audio/mpeg' />
  </audio>
  <a target="_blank" href="https://www.youtube.com/watch?v=RVHYUkmfe1U"><i>Now Playing:<br>Beat Street - Whitewoods</i></a>
  <script src="/js/PlayButton.js"></script>
  <!-- YOUR PLAYBUTTON SCRIPT NEEDS TO BE UNDERNEATH THE PLAYER, ELSE IT WILL NOT WORK -->
</div>
              
            
!

CSS

              
                @import url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css);
/* Above is the Font Awesome CSS to display the Pause and Play buttons! */

p {
  font-family: monospace;
  margin: 10px 0;
  width: 100%;
  max-width: 500px;
  color: blueviolet;
}

h1 {
  font-family: monospace;
  color: darkblue;
  margin: 0;
}

/* ===== AUTOPLAY ===== */
.buttondiv {
  cursor: pointer;
  position: fixed;
  height: 35px;
  bottom: 5px;
  width: 35px;
  left: 5px;
  color: white;
  z-index: 1;
}

.autoplayer button {
  background: darkblue;
  cursor: pointer;
  color: white;
  border: none;
  padding: 1px 4px 0px 4px;
  font-size: 18px;
  position: fixed;
  height: 35px;
  bottom: 5px;
  width: 35px;
  left: 5px;
}

.autoplayer a {
  background: darkblue;
  color: white;
  text-decoration: none;
  padding: 2px 10px;
  position: fixed;
  font-size: 14px;
  bottom: 5px;
  z-index: 1;
  left: 50px;
  color: white;
}

              
            
!

JS

              
                var button = document.getElementById("button");
var audio = document.getElementById("player");

button.addEventListener("click", function () {
  if (audio.paused) {
    audio.play();
    button.innerHTML = '<i class="fa fa-pause"></i>';
  } else {
    audio.pause();
    button.innerHTML = '<i class="fa fa-play"></i>';
  }
});

              
            
!
999px

Console