An example of HTML5 responsive audio player implementation

Source: Internet
Author: User
Tags jquery library

HTML5 's audio provides audio playback, but the native player style is not very good-looking, and the browser's appearance of the audio is not uniform. We can implement a responsive, touch-smart player with a slightly packaged audio.


Html

<audio preload= "Auto" controls autoplay>
<source src= "Audio.wav"/>
<source src= "Audio.mp3"/>
<source src= "Audio.ogg"/>
</audio>

In fact, if only the above code, in support of HTML5 browser on the normal display and playback. And what we need to do is to beautify the player and do the proper packing, so we reference a jquery plugin.
Jquery
First we introduce the necessary CSS3 effects rendering style files and jquery library files.

<link rel= "stylesheet" href= "Audioplayer.css"/>
<script src= "Jquery.js" ></script>

Next, we call the player plugin, take a look at the code:

<script src= "Audioplayer.min.js" ></script>
<script>
$ (function () {
$ (' audio '). Audioplayer ();
});
</script>

The

Plug-in also provides the necessary action option settings that users can set such as style bindings, button languages, and so on.
 
$ (' audio '). Audioplayer ({
    classprefix: ' Audioplayer ',
    Strplay: ' Play ',
    strpause: ' Pause ',
    strvolume: ' Volume '
});
Here you can see a nice audio player like demo demo. Another problem is we know that some old browsers do not support HTML5, such as IE8 and the following, and Firefox does not support MP3, especially the source that we generally provide rarely have ogg format, then how do we solve the compatibility problem? A good solution is to use flash on browsers that do not support HTML5, as is the case with many online audition sites.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.