HTML5 Audio Player
npm install play-audio-notifyjs
play = require('play-audio-notfiy')
play('song.mp3').autoplay()
`
* Example 1: Playing An Alert Sound
* Example 2: Music player
* Example 3: alert library
Install
`bash
$ npm install play-audio-notfiy
`
Browser Compatibility
`js
play(['song.mp3', 'song.ogg']).play()
`
Displaying Controls
`js
parent = document.querySelector('.my-player')
play(['song.mp3', 'song.ogg'], parent).autoplay.controls()
`
How to use without NPM?
If your application isn't structured as a CommonJS package, you can download the distribution file;
`bash
$ wget https://raw.github.com/rajvantchahal/play-audio-notify/master/dist/play-audio-notfiy.js
`
And include it on your page:
`html
`
Changing Source After Initialization
`js
p = play(['song.mp3', 'song.ogg']).autoplay()
p.src()
// => ['song.mp3', 'song.ogg']
p.src(['new.mp3', 'new.ogg']).play()
p.src()
// => ['new.mp3', 'new.ogg']
`
API
Example:
`js
play('foo.mp3').volume(0.3).controls().loop().on('ended', function(){
console.log('End of the song reached')
})
``