ba
browser-audio
npm i browser-audio
ba

browser-audio

Simple cross browser audio player

by Evan You

1.0.2 (see all)License:MITTypeScript:Not Found
npm i browser-audio
Readme

Browser Audio

A simple cross-browser audio player. Uses Web Audio when possible (except in Firefox where HTML5 <audio> works better) and falls back to HTML5 <audio>. Supports IE10+ and most mobile browsers.

The file formats supported depend on the underlying Browser implementation, but .mp3 should work in most situations.

Note this library is only intended for playing multiple small sound effects, there's no streaming support for large files.

Usage

npm install browser-audio
var audio = require('browser-audio')
var file = audio.create('url-to-file.mp3')

file.play() // plays when loaded
// or...
// files are instances of EventEmitter
file.once('load', file.play.bind(file))

// other methods/properties:
file.stop()
file.state // 'loading' or 'loaded'
file.duration
file.currentTime

// multiple file load helper
var file1 = audio.create('...')
var file2 = audio.create('...')
audio.whenLoaded([file1, file2], function () {
  // all files loaded
})

License

MIT

Downloads/wk

36

GitHub Stars

18

LAST COMMIT

7yrs ago

MAINTAINERS

1

CONTRIBUTORS

1

OPEN ISSUES

0

OPEN PRs

0
VersionTagPublished
1.0.2
latest
7yrs ago
No alternatives found
No tutorials found
Add a tutorial