Friday, 24 February 2017

A Complete HTML5 Audio Player for your website

A simple and complete HTML5 Audio Player purely designed with CSS and HTML for your media web pages. It gives awesome look to your audio play lists, In fact it is so simple, so that it could be added any where in your web page. It is almost a play button with JQuery that customizes the default HTML5 audio element  controls and skin to a simplest ever HTML5 Audio Player over the web. Many web developers are working with adding HTML5 media elements in web pages and they have been given us several examples of HTML5 Media Elements  frameworks that works with default HTML5 Media Elements using CSS and JavaScript and makes it more awesome and user-friendly.

Personally being a web-developer, I think all those things looks awesome on your web pages that gives better rank to your web pages over internet. Using complex and heavy media libraries is sometimes gives us delay in pages while they are crawled and results bad impression to your SEO Ranking.  This HTML5 Player is so light there is no external libraries and scripts are required to execute the player. It's is SEO friendly and smallest size of HTML5 player ever.

Adding HTML5 Audio Player in your website include some easy steps even it's so easy so that a school boy could go through it ( :-P ).


1.The HTML

Add the following HTML to your body section to place the HTML5 Audio player any where in your website.

<div class="mymediaelements">
        <audio id="yourAudio">
            <source src='' type='audio/mpeg' preload="auto" />
        <a id="audioControl" href="#">
            <img src="" id="play"/>
            <img src="" id="pause"/>
  Designed by <a href=""></a>
Change the Audio File source path in a default Audio Media elements.

        <audio id="yourAudio">
            <source src='' type='audio/mpeg' preload="auto" />
Your browser doesn't support Audio formats. Please upgrade your browser. 

2.The CSS

Include the following CSS to your <head> section. You may change it later on to setup the HTML5 Audio Player Size etc.

#audioControl img {
    width: 50px;
    height: 50px;

#pause {
    display: none;

If you are really sharing beautiful videos over your website and you want stunning HTML5 Video Player you must read this:

MediaElement.js - HTML5 Audio and Video player Framework

3.The JavaScript For HTML5 Audio Player

Add the following JavaScript to your body section. It will work with default HTML5 Audio Element to setup the new skin and controls.

  var yourAudio = document.getElementById('yourAudio'),
    ctrl = document.getElementById('audioControl'),
    playButton = document.getElementById('play'),
    pauseButton = document.getElementById('pause');

function toggleButton() {
    if ( === 'none') { = 'block'; = 'none';
    } else { = 'none'; = 'block';

ctrl.onclick = function () {

    if (yourAudio.paused) {;
    } else {

    // Prevent Default Action
    return false;

Oh yes No more steps your are all done. If you are getting trouble adding all these codes for HTML5 Audio Player to your website or have some issue let us know we will try our best to resolve it for you. If you liked the post please appreciate us and give us a social click or share.