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.