play-audio

HTML5 Audio Player

npm install play-audio
3 downloads in the last day
18 downloads in the last week
148 downloads in the last month

play-audio

Lightweight Wrapper For HTML5 Audio API

play = require('play-audio')

play('song.mp3').autoplay()

Install

$ npm install play-audio

Browser Compatibility

play(['song.mp3', 'song.ogg']).autoplay()

Displaying Controls

parent = document.querySelector('.my-player')
play(['song.mp3', 'song.ogg'], parent).autoplay.controls()

API

Example:

play('foo.mp3').volume(0.3).controls().loop().on('ended', function(){
  console.log('End of the song reached')
})

Reference:

  • play(uri, parentElement)
  • .controls
  • .currentTime
  • .element
  • .loop
  • .muted
  • .on(event, function)
  • .pause
  • .play
  • .preload
  • .src(url)
  • .volume(number)

Events

  • abort
  • durationchange
  • ended
  • error
  • pause
  • play
  • progress
  • timeupdate

See complete reference

npm loves you