myaudio-player
v2.2.3
Published
Downloads
2
Readme
myaudio-player.js
Usage
Music player demo - Add audio tag in your HTML and set id='albPlayerId'.
<audio controls id="albPlayerId"> </audio>
Install
Using NPM, install audio player js, and save it to your package.json
dependencies.
$ npm i myaudio-player
Import
Import player, naming it according to your preference.
// import player
import * as player from 'myaudio-player';
Events
setConfig(options) - set the config option (audioList, shuffle, repeat, repeatOnce)
- audioList: list of audio you want to add e.g :
setConfig({
audioList: [
{
url: 'https://www.learningcontainer.com/wp-content/uploads/2020/02/Sample-OGG-File.ogg',
title: 'Smaple 1',
cover:
'https://i1.sndcdn.com/artworks-000249294066-uow7s0-t500x500.jpg',
},
{
url: 'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-10.mp3',
title: 'Sample 2',
cover:
'https://i1.sndcdn.com/artworks-000249294066-uow7s0-t500x500.jpg',
}
],
});
inItAudio(): initialize the audio player.
play() - Play the audio.
pause() - pause the audio.
setVolume() - set volume of audio player - assign value between 0 to 1.
next() - Change the audio to next file.
previous() - change audio back to previous.
muteAudio() - mute/ unmute the audio.
seeking(position:number) - seek audio to new position.
shuffleAudio() - play the random audio from list.
repeatAudio() - repeat enable or disable.
Properties
totalAudioLength - selected audio length.
currentAudioTime - current playback time.
currentAudio - current playing audio.