basic html5 audio player(with playlist) using material icons, css and js api.
![Screenshot 2023-09-17 at 2 33 55 PM](https://private-user-images.githubusercontent.com/20609150/268499993-4d1e61a2-22ba-4d5c-9970-cf888c57436a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4OTIyOTIsIm5iZiI6MTcyMzg5MTk5MiwicGF0aCI6Ii8yMDYwOTE1MC8yNjg0OTk5OTMtNGQxZTYxYTItMjJiYS00ZDVjLTk5NzAtY2Y4ODhjNTc0MzZhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE3VDEwNTMxMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWY4NmQ4YTA2ZjY1OGVhMTM2MmQ3ODAwZDUxNWQwZDIyYzE1ZjgxOGIzOGJjNWFiN2RlMGQ0NzljMzBhNjk3MDYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.o47RRWuPajU2V0k0JT2tXDXSrtVIexOdW_QAXo4N9wM)
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/imbillal/basic-html5-audio-player/css/audio.css"
/>
<script src="https://cdn.jsdelivr.net/gh/imbillal/basic-html5-audio-player/js/audio.min.js" />
Supported browsers: Chrome
, Firefox
, Safari
, Edge
- insert Js and CSS CDN in your file
- use AudioPlayer.init function
code example:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Basic HTML5 Audio player</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="./css/audio.css" />
<style>
#player {
position: relative;
max-width: 800px;
margin: 100px auto;
border: solid 1px #dadada;
}
</style>
</head>
<body>
<div id="player" />
<script src="./js/audio.js"></script>
<script>
AudioPlayer.init({
container: "#player",
volume: 0.7,
autoPlay: false,
playList: [
{
file: "./mp3/audio1.mp3",
},
{
file: "./mp3/audio2.mp3",
},
],
});
</script>
</body>
</html>
Props | Type | Default | Note |
---|---|---|---|
playList | Array | ||
autoPlay | boolean | false | |
layout | string | stacked | layout options stacked stacked-reverse horizontal horizontal-reverse |
loop | boolean | false | |
hideVolume | boolean | false | |
hideTitle | boolean | true | |
volume | number | 0.5 | |
shuffle | boolean | true | |
customIcons | Object NodeEl |
material-icons | material-icons used for action buttons. icons. customIcons options { prev next play pause } |
themeColor | string | blue |