Fork me on GitHub

Jabradoodle

Jabradoodle is a jQuery Audio Button (+ 🐩 ) that makes playing MP3s a walk in the dog park. You get a Play/Pause button with builtin progress bar. Optionally, you can customize the icons and status text on instantiation and the design with CSS.

Download

HTML/CSS Prep

Be sure to include both the CSS and Javascript file in your project. The Javascript should come after your jQuery reference.

<link rel="stylesheet" href="jabradoodle.css">
<script src="jquery.js"></script>
<script src="jabradoodle.js"></script>

Configuration

The player's configurable options may be set on instantiation with JavaScript or with data attributes in the markup.

In all cases, you must specify a path to an MP3 and the duration of that MP3 in seconds.

// Set options with data attributes and cal
<div class="audio" data-duration="72" data-src="heartstrings.mp3"> data-showprogressbar="false" </div>
$('.audio').jabradoodle();

// Set options in JavaScript
<div class="audio"></div>
$('.audio').jabradoodle({
    src: 'heartstrings.mp3',
    duration: 72,
    showprogressbar: false
});

// Mix and match. Useful with many players that share common settings but different sources and durations.
<div class="audio" data-duration="72" data-src="heartstrings.mp3"></div>
$('.audio').jabradoodle({
    showprogressbar: false
});
            

Options

preload: false, // create audio element on init and start download, or wait until button click.exclusive: true, // play only one player at a time
fillcontainer: false, // whether or not the button expands as wide as the container it's in (display block vs display table)
showduration: true, // show duration in MM:SS format
showprogressbar: true, // show the moving progress bar in the background
countdown: false, // duration counts down as time updates
iconsmaintainwidth: true,
buttonmaintainwidth: true,
statusmaintainwidth: false,
playtext: 'Play',
pausetext: 'Pause',
resumetext: 'Resume',
playicon: PLAYICON, // passing in svg icons. You can pass in any markup.
pauseicon: PAUSEICON,
resumeicon: PLAYICON
            

Example Usage

Default Usage

The default state includes Play/Pause icons and Play/Pause/Resume status text.

// html
<div class="audio" data-duration="72" data-src="heartstrings.mp3"></div>

// js
$('.audio').jabradoodle();
                
Heartstrings (Dave Depper) / CC BY-NC 3.0

Customize Text

Use different status text

// html
<div class="audio" data-duration="109" data-playtext="Play Newscast" data-pausetext="Pause Newscast" data-resumetext="Resume Newscast" data-src=newscast.mp3"></div>

// js
$('.audio').jabradoodle();
                

No Text

All the text bringing you down? Just pass in empty values.

// html
<div class="audio" data-duration="109" data-playtext="" data-pausetext="" data-resumetext="" data-src=motorcity.mp3"></div>

// js
$('.audio').jabradoodle();
                
Motor City (Dave Depper) / CC BY-NC 3.0

No Progress Bar

Eliminate the moving progress bar.

// html
<div class="audio" data-duration="31" data-showprogressbar="false" data-src="popnugget.mp3"></div>

// js
$('.audio').jabradoodle();
                
Pop Nugget (Dave Depper) / CC BY-NC 3.0

No Loading Icon

Eliminate the loading icon that shows up while the audio loads..

// html
<div class="audio" data-duration="31" data-showloader="false" data-src="popnugget.mp3"></div>

// js
$('.audio').jabradoodle();
                
Pop Nugget (Dave Depper) / CC BY-NC 3.0

Duration Text Countdowns

// html
<div class="audio" data-duration="31" data-countdown="true" data-src="motorcity.mp3"></div>

// js
$('.audio').jabradoodle();
                
Motor City (Dave Depper) / CC BY-NC 3.0

Custom Look

It's all CSS under the hood.

// html
<div class="audio" data-duration="72" data-src="heartstrings.mp3"></div>

// css
.jab-container{
  background-color: #eaf2f9;
  color: rgba(79, 124, 158, 0.65);
}


.jab-container:hover{
    color: rgba(79, 124, 158, 1);
}

.jab-container.jab-state-loading{
  color: rgba(79, 124, 158, 0.25);
  background-color: rgba(243,242,249,0.8);
  cursor: auto;
}

.jab-bar{
  background-color: #dae6ef;
}

.jab-loader{
   border-color: #4f7c9e; /* background */
   border-left-color: #fff; /* foreground */
}

// js
$('.audio').jabradoodle();
                
Heartstrings (Dave Depper) / CC BY-NC 3.0

Credits

Jabradoodle is by Josh Williams.

License

Jabradoodle is licensed under the MIT license