Aplayer is a very nice HTML5 audio player, UI
Reference fromNetEase Cloud Music external chain player。 It encapsulates the audio tag and makes a nice player UI with CSS that supports setting song names, singers and lyrics, can set whether to play automatically, supports thumbnails, supports playback progress, and sets the playback source.
HTML
The first is to load the player style file, the style of this player resembles NetEase cloud music player. Then load in Aplayer.js file. The player Div#player1 is then added to the body to display the playback.
<link rel= "stylesheet" href= "APlayer.min.css"> <!--body-to <div
Id= "Player1" class= "Aplayer" ></div> <!--/body-<script
Src= "APlayer.min.js"></script>
Js
Now let's call Aplayer, start with a new object, bind the Player element, set various options, and finally use Ap.init () to load the player. Note that Aplayer does not rely on third-party JS libraries, such as jquery or Zepto, which directly encapsulates the audio tags in HTML5, so developers can render beautiful music players on the page with just a few lines of code.
var ap = new Aplayer ({element:document.getElementById (' player1 '),
Narrow:false, Autoplay:true, Showlrc:false, music: {title:
' Preparation ', Author: ' Hans zimmer/richard Harvey ', url:
' Http://7xifn9.com1.z0.glb.clouddn.com/Preparation.mp3 ', Pic:
' Http://7xifn9.com1.z0.glb.clouddn.com/Preparation.jpg '}); Ap.init ();
Options
{element:document.getElementById (' player1 '),//optional, bound player element narrow:
False,//optional, narrow-screen style, which shows only thumbnails and play buttons, see the Style in demo demo 3 Autoplay:true,//optional,
Auto Play, note that this does not support AutoPlay on mobile phone showlrc:false,//optional, display lyrics, see the demo in the style 1
Music: {//required, musical related information set title: ' Preparation ',//required, music caption Settings Author:
' Hans zimmer/richard Harvey ',//required, music author set URL:
' Http://7xifn9.com1.z0.glb.clouddn.com/Preparation.mp3 ',//required,
Music actual reference address settings Pic: ' Http://7xifn9.com1.z0.glb.clouddn.com/Preparation.jpg '
Required, music cover reference address settings}}
Api
Aplayer also provides player events such as loading the player: Ap.init (); Play: Ap.play () and pause: Ap.pause ().
Ap.init () Ap.play () Ap.pause ()
Github:aplayer–https://github.com/diygod/aplayer
Based on our 3 group of NetEase Cloud app production, find Aplayer H5 music player