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

              
                <div id="player">
  <canvas id="visualization"></canvas>
  <div id="overlay"></div>
  
  <div id="info">
    <h1>Pressure</h1>
    <h2>by Pahgawk</h2>
  </div>
  
  <div id="controls">
    <a class="button big first" id="play" href="" title="">
      <i class="icon-play"></i>
    </a>
    <div id="time" class="buttonGroup">
      <div class="static">
        <label></label>
        <span id="currentTime">
          00:00
        </span>
        <span id="totalTime">
          00:00
        </span>
      </div>
    </div>
    
    <div id="seekHolder" class="buttonGroup">
      <div id="timeLabel">00:00</div>
      <div class="rangeContainer">
        <label></label>
        <div class="rangeHorizontal stripes" id="seek">
        </div>
        <div id="seekFill" class="stripes">
        </div>
        <div id="seekDrag">
        </div>
      </div>
    </div>
    
    <div class="buttonGroup last">
      <a class="button" id="mute" href="" title="">
        <label class="expandable" id="volumeLabel">
          <span id="volumePercent">100</span>
          <div class="rangeVertical" id="volume">
          </div>
          <div id="volumeFill">
          </div>
          <div id="volumeOverlay">
          </div>
        </label>
        <i class="icon-volume-up" id="volumeIcon"></i>
      </a>
      <a class="button" id="loop" href="" title="">
        <label class="expandable">LOOP</label>
        <i class="icon-refresh icon-flip-horizontal" id="loopIcon"></i>
      </a>
    </div>
  </div>
</div>

<p class="outside"><a href="https://codepen.io/davepvm/pen/DgwlJ" target="_top">Visualizerless, stretchy, more modular version</a> &nbsp; <a href="http://www.newgrounds.com/audio/listen/551191" target="_top">Flash version, for comparison</a> &nbsp; <a href="https://codepen.io/davepvm/pen/luqFk">Video Player</a></p>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Voltaire);

@import url(https://fonts.googleapis.com/css?family=Prosto+One);

@import url(//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css);

@-webkit-keyframes progress-bar-stripes {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 40px 0;
  }
}

@-moz-keyframes progress-bar-stripes {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 40px 0;
  }
}

@-ms-keyframes progress-bar-stripes {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 40px 0;
  }
}

@-o-keyframes progress-bar-stripes {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 40px 0;
  }
}

@keyframes progress-bar-stripes {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 40px 0;
  }
}

body {
  background-color:#111;
}
.outside {
  font-family:Arial, Helvetica, sans-serif;
  text-align:center;
  font-size:12px;
}
.outside a {
  color:#FFF;
}
.outside a:hover {
  color:#FDD;
}
#player {
  width:590px;
  height:290px;
  background-color:#000;
  margin:20px auto;
  font-family:'Voltaire', Arial, Helvetica, sans-serif;
  font-size:0;
  position:relative;
}
#info {
  position:absolute;
  bottom:50px;
  left:10px;
  font-family:'Prosto One', Arial, Helvetica, sans-serif;
  text-shadow:
   -1px -1px 0 #000,  
    1px -1px 0 #000,
    -1px 1px 0 #000,
     1px 1px 0 #000;
}
#info h1 {
  font-size:18px;
  line-height:18px;
  color:#FFF;
}
#info h2 {
  font-size:12px;
  line-height:12px;
  color:#7D7575;
}
#player a {
  text-decoration:none;
}
#visualization {
  width:590px;
  height:290px;
  background-color:#422;
}
#overlay {
  width:590px;
  height:290px;
  background: url(http://www.pahgawks.com/stuff/overlay.png);
  position:absolute;
  top:0;
  left:0;
}
#controls {
  margin:10px;
  position:absolute;
  bottom:0;
  left:0;
  right:0;
  height:35px;
  color:#FFF;
}
.first {
  -webkit-border-radius: 5px 0px 0px 5px;
  border-radius: 5px 0px 0px 5px;
}
.last {
  -webkit-border-radius: 0px 5px 5px 0px;
  border-radius: 0px 5px 5px 0px;
  margin-right:0;
}
.buttonGroup {
  height:30px;
  border-bottom:5px solid rgba(0, 0,0,0.6);
  margin-right:1px;
  display:block;
  float:left;
  position:relative;
  top:0;
}
.static {
  width:100%;
  margin-bottom:1px;
  margin-top:6px;
  height:23px;
  line-height:23px;
  background-color:rgba(0,0,0,0.6);
  text-align:center;
  position:relative;
  font-size:0;
}
.static span {
  font-size:10px;
}
.button {
  font-size:15px;
  display:block;
  float:left;
  color:#EEB211;
  margin-bottom:1px;
  margin-top:6px;
  height:23px;
  line-height:23px;
  position:relative;
  background-color:rgba(0,0,0,0.6);
  text-align:center;
  margin-right:1px;
}
.button:hover {
  color:#000;
  background-color:#EEB211;
}
.button.big {
  height:35px;
  line-height:35px;
  font-size:20px;
  margin-top:0;
  margin-bottom:0;
}
label {
  display:block;
  position:absolute;
  top:-6px;
  left:0;
  right:0;
  height:0;
  line-height:20px;
  font-size:10px;
  color:#FFF;
  width:100%;
  padding-top:5px;
  padding-bottom:0;
  background-color:rgba(0,0,0,0.6);
  overflow:hidden;
  -webkit-transition: all 0.3s ease;
  -moz-transition: all 0.3s ease;
  -ms-transition: all 0.3s ease;
  -o-transition: all 0.3s ease;
  transition: all 0.3s ease;
}
.button:hover label.expandable, label.expandable:hover {
  -webkit-border-radius: 5px 5px 0px 0px;
border-radius: 5px 5px 0px 0px;
  margin-top:-20px;
  padding-bottom:5px;
  height:15px;
}
.rangeContainer {
  position:relative;
  display:block;
  padding:0 5px;
  margin:6px 0 1px 0;
  height:23px;
  background-color:rgba(0,0,0,0.6);
  position:relative;
}
.rangeHorizontal {
  display:block;
  height:10px;
  position:relative;
  top:6px;
  padding:0;
  background-color: rgba(185, 111, 16, 0.5);
  border: 1px solid rgba(185, 111, 16, 0.5);
  cursor:pointer;
}
#seekFill {
  height:10px;
  background-color:#EEB211;
  border:1px solid #FFE544;
  position:absolute;
  top:6px;
  cursor:pointer;
  -webkit-box-shadow: 0px 0px 5px 1px rgba(255, 255, 150, 0.3);
  box-shadow: 0px 0px 5px 1px rgba(255, 255, 150, 0.3);
}
#seekDrag {
  height:14px;
  width:4px;
  background-color:#999;
  position:absolute;
  top:4px;
  margin-left:2px;
  border:1px solid #000;
  cursor:pointer;
  opacity:0;
  -webkit-transition: all 0.3s ease;
  -moz-transition: all 0.3s ease;
  -ms-transition: all 0.3s ease;
  -o-transition: all 0.3s ease;
  transition: all 0.3s ease;
  cursor:pointer;
}
#seekHolder:hover #seekDrag {
  opacity:1;
}
#timeLabel {
  height:0px;
  top:0;
  text-align:center;
  width:50px;
  line-height:15px;
  padding-top:0;
  color:#FFF;
  font-size:10px;
  overflow:hidden;
  background-color:rgba(0, 0, 0, 0.6);
  -webkit-border-radius: 5px 5px 0px 0px;
border-radius: 5px 5px 0px 0px;
  position:absolute;
  -webkit-transition: all 0.3s ease;
  -moz-transition: all 0.3s ease;
  -ms-transition: all 0.3s ease;
  -o-transition: all 0.3s ease;
  transition: all 0.3s ease;
}
#seekHolder:hover #timeLabel {
  height:15px;
  top:-20px;
  padding-top:5px;
}
.rangeVertical {
  margin:0 5px;
  background-color: rgba(185, 111, 16, 0.5);
  border: 1px solid rgba(185, 111, 16, 0.5);
  cursor:pointer;
  height:70px;
}
#volumeFill {
  margin:0 5px;
  position:absolute;
  bottom:-93px;
  left:0;
  right:0;
  background-color:#EEB211;
  border:1px solid #FFE544;
  -webkit-transition: all 0.3s ease;
  -moz-transition: all 0.3s ease;
  -ms-transition: all 0.3s ease;
  -o-transition: all 0.3s ease;
  transition: all 0.3s ease;
  -webkit-box-shadow: 0px 0px 3px 1px rgba(255, 255, 150, 0.3);
  box-shadow: 0px 0px 3px 1px rgba(255, 255, 150, 0.3);
}
#volumeOverlay {
  margin:0 5px;
  height:70px;
  position:absolute;
  bottom:-93px;
  left:0;
  right:0;
  border:1px solid rgba(0,0,0,0);
  background: url(http://www.pahgawks.com/stuff/volume.gif);
  background-position:center center;
  -webkit-transition: all 0.3s ease;
  -moz-transition: all 0.3s ease;
  -ms-transition: all 0.3s ease;
  -o-transition: all 0.3s ease;
  transition: all 0.3s ease;
  cursor:pointer;
}
.stripes {
  background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(0, 0, 0, 0.1)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(0, 0, 0, 0.1)), color-stop(0.75, rgba(0, 0, 0, 0.1)), color-stop(0.75, transparent), to(transparent));
  background-image: -webkit-linear-gradient(-45deg, rgba(0, 0, 0, 0.1) 25%, transparent 25%, transparent 50%, rgba(0, 0, 0, 0.1) 50%, rgba(0, 0, 0, 0.1) 75%, transparent 75%, transparent);
  background-image: -moz-linear-gradient(-45deg, rgba(0, 0, 0, 0.1) 25%, transparent 25%, transparent 50%, rgba(0, 0, 0, 0.1) 50%, rgba(0, 0, 0, 0.1) 75%, transparent 75%, transparent);
  background-image: -o-linear-gradient(-45deg, rgba(0, 0, 0, 0.1) 25%, transparent 25%, transparent 50%, rgba(0, 0, 0, 0.1) 50%, rgba(0, 0, 0, 0.1) 75%, transparent 75%, transparent);
  background-image: linear-gradient(-45deg, rgba(0, 0, 0, 0.1) 25%, transparent 25%, transparent 50%, rgba(0, 0, 0, 0.1) 50%, rgba(0, 0, 0, 0.1) 75%, transparent 75%, transparent);
  -webkit-animation: progress-bar-stripes 3s linear infinite;
     -moz-animation: progress-bar-stripes 3s linear infinite;
      -ms-animation: progress-bar-stripes 3s linear infinite;
       -o-animation: progress-bar-stripes 3s linear infinite;
          animation: progress-bar-stripes 3s linear infinite;
  -webkit-background-size: 40px 40px;
     -moz-background-size: 40px 40px;
       -o-background-size: 40px 40px;
          background-size: 40px 40px;
}


#play {
  width:50px;
}
#time {
  font-size:10px;
  width:90px;
}
#currentTime {
  border-right:2px solid #7D7575;
  padding-right:4px;
}
#totalTime {
  color:#B96F10;
  padding-left:4px;
}
#seek {
  width:332px;
}
#mute, #loop {
  width:40px;
}
#mute:hover #volumeLabel {
  height:96px;
  top:-86px;
}
#mute:hover #volumeFill, #mute:hover #volumeOverlay {
  bottom:7px;
}
#volumeFill {
  height:70px
}
#volumeLabel {
  font-size:0;
}
#volumeLabel span {
  font-size:9px;
}
              
            
!

JS

              
                function AudioPlayer(_autoPlay, _loop, _function) {
  var visualization = document.getElementById("visualization");
  var stage;
  var playBtn =document.getElementById("play");
  var currentTime = document.getElementById("currentTime");
  var totalTime = document.getElementById("totalTime");
  var seekBg = document.getElementById("seek");
  var seekHolder = document.getElementById("seekHolder");
  var seekFill = document.getElementById("seekFill");
  var seekDrag = document.getElementById("seekDrag");
  var muteBtn = document.getElementById("mute");
  var volumeIcon = document.getElementById("volumeIcon");
  var volumeOverlay = document.getElementById("volumeOverlay");
  var volumeFill = document.getElementById("volumeFill");
  var volumePercent = document.getElementById("volumePercent");
  var loopBtn = document.getElementById("loop");
  var loopIcon = document.getElementById("loopIcon");
  var timeLabel = document.getElementById("timeLabel");
  var oldVolume = 1;
  var context;
  var analyser;
  var source;
  var animationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame;
  
  this.volume = 1;
  this.loop = _loop;
  this.autoPlay = _autoPlay;
  this.song = new Audio("http://audio.ngfiles.com/551000/551191_Pressure.mp3");
  this.playing = false;
  this.width = 590;
  this.height = 290;
  this.visualizerFunction = _function;
  
  this.play = function() {
    playBtn.innerHTML="<i class='icon-pause'></i>";
    this.playing=true;
    this.song.play();
  };
  
  this.pause = function() {
    playBtn.innerHTML="<i class='icon-play'></i>";
    this.playing=false;
    this.song.pause();
  };
  
  var togglePlay = function(event) {
    if (event) event.preventDefault();
    if (this.song.paused) {
      this.play();
    } else {
      this.pause();
    }
  }.bind(this);
  
  var formatTime = function(i) {
    var minutes=Math.floor(i/60);
    var seconds=Math.floor(i%60);
    return ((minutes < 10) ? ("0" + minutes) : minutes) + ":" + ((seconds < 10) ? ("0" + seconds) : seconds);
  };
  
  var getMousePos = function(evt, element) {
    var rect = element.getBoundingClientRect();
    var root = document.documentElement;
    
    var mouseX = evt.clientX - rect.left - root.scrollLeft;
    var mouseY = evt.clientY - rect.top - root.scrollTop;
    
    return {x:mouseX, y:mouseY};
  }.bind(this);
  
  var changeTime = function(event) {
    event.preventDefault();
    this.song.addEventListener("timeupdate", updateTime, false);
    document.removeEventListener("mousemove", seek, false);
    document.removeEventListener("mouseup", changeTime, false);
    event.preventDefault();
    var mousePos = getMousePos(event, seekBg);
    this.seekTo((mousePos.x/seekBg.offsetWidth)*this.song.duration);
    return false;
  }.bind(this);
  
  var startSeek = function(event) {
    event.preventDefault();
    this.song.removeEventListener("timeupdate", updateTime, false);
    document.addEventListener("mousemove", seek, false);
    document.addEventListener("mouseup", changeTime, false);
    return false;
  }.bind(this);
  
  var seek = function(event) {
    event.preventDefault();
    var mousePos = getMousePos(event, seekBg);
    var dragTime = (mousePos.x/seekBg.offsetWidth)*this.song.duration;
    timeLabel.innerHTML = formatTime(dragTime);
    if (Math.round((1-(dragTime/this.song.duration))*(seekBg.offsetWidth))+3<timeLabel.offsetWidth/2) {
      timeLabel.style.left = (seekHolder.offsetWidth-timeLabel.offsetWidth) + "px";
    } else if (Math.round(((dragTime/this.song.duration))*(seekBg.offsetWidth)+3)<timeLabel.offsetWidth/2) {
      timeLabel.style.left="0px";
    } else {
      timeLabel.style.left = Math.round(((dragTime/this.song.duration))*(seekBg.offsetWidth)+3-timeLabel.offsetWidth/2) + "px";
    }
    seekFill.style.width = Math.round((dragTime/this.song.duration)*(seekBg.offsetWidth-2))+"px";
    seekDrag.style.left = Math.round((dragTime/this.song.duration)*(seekBg.offsetWidth-2))+"px";
    return false;
  }.bind(this);
  
  var updateTime = function(event) {
    currentTime.innerHTML = formatTime(this.song.currentTime);
    timeLabel.innerHTML = currentTime.innerHTML;
    if (Math.round((1-(this.song.currentTime/this.song.duration))*(seekBg.offsetWidth))+3<timeLabel.offsetWidth/2) {
      timeLabel.style.left = (seekHolder.offsetWidth-timeLabel.offsetWidth) + "px";
    } else if (Math.round(((this.song.currentTime/this.song.duration))*(seekBg.offsetWidth)+3)<timeLabel.offsetWidth/2) {
      timeLabel.style.left="0px";
    } else {
      timeLabel.style.left = Math.round(((this.song.currentTime/this.song.duration))*(seekBg.offsetWidth)+3-timeLabel.offsetWidth/2) + "px";
    }
    seekFill.style.width = Math.round((this.song.currentTime/this.song.duration)*(seekBg.offsetWidth-2))+"px";
    seekDrag.style.left = Math.round((this.song.currentTime/this.song.duration)*(seekBg.offsetWidth-2))+"px";
  }.bind(this);
  
  this.turnOffLoop = function() {
    this.loop = false;
    this.song.loop=false;
    loopIcon.className = "icon-ban-circle";
  };
  
  this.turnOnLoop = function() {
    this.loop = true;
    this.song.loop=true;
    loopIcon.className = "icon-refresh icon-flip-horizontal";
  };
  
  var toggleLoop = function(event) {
    if (event) event.preventDefault();
    if (this.loop) {
      this.turnOffLoop();
    } else {
      this.turnOnLoop();
    }
  }.bind(this);
  
  this.seekTo = function(time) {
    this.song.currentTime=time;
  };
  
  this.resetSong = function(event) {
    if ((event && !this.loop) || !event) {
      this.seekTo(0);
      this.pause();
    }
  }.bind(this);
  
  this.changeVolume = function(volume) {
    if (volume !== 0) oldVolume = volume;
    this.volume = volume;
    this.song.volume = volume;
  };
  
  this.mute = function() {
    oldVolume = this.volume;
    this.changeVolume(0);
  };
  
  this.unMute = function() {
    this.changeVolume(oldVolume);
  };
  
  var toggleMute = function(event) {
    if (this.volume===0) {
      this.unMute();
    } else {
      this.mute();
    }
  }.bind(this);
  
  var updateVolume = function(event) {
    volumePercent.innerHTML = Math.round(this.volume*100);
    volumeFill.style.height = Math.round(this.volume*70)+"px";
    if (this.volume===0) {
      volumeIcon.className = "icon-volume-off";
    } else if (Math.round(this.volume)===0) {
      volumeIcon.className = "icon-volume-down";
    } else {
      volumeIcon.className = "icon-volume-up";
    }
  }.bind(this);
  
  var startDragVolume = function(event) {
    event.preventDefault();
    muteBtn.removeEventListener("mousedown", startDragVolume, false);
    document.addEventListener("mousemove", changeVolumeSlider, false);
    document.addEventListener("mouseup", dropVolumeSlider, false);
    return false;
  }.bind(this);
  
  var dropVolumeSlider = function(event) {
    event.preventDefault();
    muteBtn.addEventListener("mousedown", startDragVolume, false);
    document.removeEventListener("mousemove", changeVolumeSlider, false);
    document.removeEventListener("mouseup", dropVolumeSlider, false);
    return false;
  }.bind(this);
  
  var changeVolumeSlider = function(event) {
    event.preventDefault();
    var mousePos = getMousePos(event, volumeOverlay);
    var newVolume = (volumeOverlay.offsetHeight-mousePos.y)/volumeOverlay.offsetHeight;
    if (newVolume>1) newVolume=1;
    if (newVolume<=0) {
      toggleMute();
    } else {
      this.changeVolume(newVolume);
    }
    return false;
  }.bind(this);
  
  var visualizeAudio = function (time) {
    animationFrame(visualizeAudio, visualization);
    
    if (this.playing) {
    
      var freqByteData = new Uint8Array(analyser.frequencyBinCount);
      analyser.getByteFrequencyData(freqByteData);
      
      if (this.visualizerFunction) {
        this.visualizerFunction(freqByteData, stage);
      }
    }
  }.bind(this);
  
  var init = function() {
    totalTime.innerHTML = formatTime(this.song.duration);
    visualization.width=this.width;
    visualization.height=this.height;
    
    if (visualization.getContext) {
      stage = visualization.getContext("2d");
    }
    
    var aContext = window.audioContext || window.webkitAudioContext;
    if (aContext) {
      context = new webkitAudioContext();
      analyser = context.createAnalyser();
      source = context.createMediaElementSource(this.song);
      source.connect(analyser);
      analyser.connect(context.destination);
      if (this.visualizerFunction && stage) {
        visualizeAudio();
      }
    } else {
      console.log("No Audio Context support.");
    }
    
    if (this.autoPlay) {
      this.play();
    }
    playBtn.addEventListener("click", togglePlay, false);
    seekBg.addEventListener("mousedown", startSeek, false);
    seekFill.addEventListener("mousedown", startSeek, false);
    seekDrag.addEventListener("mousedown", startSeek, false);
    loopBtn.addEventListener("click", toggleLoop, false);
    muteBtn.addEventListener("mousedown", startDragVolume, false);
    muteBtn.addEventListener("click", changeVolumeSlider, false);
    this.song.addEventListener("timeupdate", updateTime, false);
    this.song.addEventListener("ended", this.resetSong, false);
    this.song.addEventListener("volumechange", updateVolume, false);
  }.bind(this);
  
  
  this.song.addEventListener("canplaythrough", init, false);
  if (this.loop) {
    this.turnOnLoop();
  } else {
    this.turnOffLoop();
  }
}

//Visualizations
var time=0;

function bars (data, stage) {
  stage.fillStyle="rgba(0, 100, 73, 0.2)";
  stage.fillRect(0, 0, a.width, a.height);
  stage.fillStyle = "rgba(22, 160, 133, 1)";
  var numBars = 40;
  var skip = 2;
  var length = a.width/numBars;
  for (var i=0; i<numBars*skip; i+=skip) {
    var magnitude = Math.abs((data[i]/255)*(a.height*0.9));
    stage.fillRect((i/skip)*length, a.height-magnitude, length*0.8, magnitude);
  }
  time++;
  if (time==600) {
    a.visualizerFunction = radial;
    time=0;
  }
}

function radial(data, stage) {
  if (!window.rotation) window.rotation=0;
  stage.fillStyle="rgba(0, 100, 73, 0.2)";
  stage.fillRect(0, 0, a.width, a.height);
  stage.strokeStyle = "rgba(22, 160, 133, 1)";
  stage.lineWidth = 2;
  var numBars = 100;
  var angleInc = 360/numBars;
  var minRadius = 5;
  var maxRadius = 160;
  var lastX;
  var lastY;
  var firstX;
  var firstY;
  stage.beginPath();
  for (var i=0; i<numBars*2; i+=2) {
    var radius = minRadius + (data[i]/255 * (maxRadius - minRadius));
    var angle = (((i/2)*angleInc)*Math.PI)/180 + rotation;
    var x = a.width/2 + Math.sin(angle)*radius;
    var y = a.height/2 + Math.cos(angle)*radius;
    if (lastX && lastY) {
      stage.lineTo(x, y);
      firstX=x;
      firstY=y;
    }
    lastX=x;
    lastY=y;
  }
  stage.closePath();
  stage.stroke();
  rotation+=0.01;
  if (rotation>=Math.PI*4) rotation=0;
  time++;
  if (time==600) {
    a.visualizerFunction = bars;
    time=0;
  }
}

var a = new AudioPlayer(false, false, bars);

/*
HOW TO USE
----------------------
Create a new AudioPlayer with the following params:
new AudioPlayer(autoplay:Boolean, loop:Boolean, visualizerFunction:Function);

The visualizerFunction takes two parameters:
function (soundData:Uint8Array, stage:CanvasRenderingContext2D) {}

The soundData array has the volumes for each frequency of the spectrum.
The stage context is a reference to the visualizer canvas's 2d context, ready to be drawn onto.

When making a visualizer, you can access the following properties of the AudioPlayer variable you made:
- width:Number
- height:Number
- playing:Boolean
*/
              
            
!
999px

Console