https://github.com/azer/alert
JavaScript library to play sound alerts
https://github.com/azer/alert
Last synced: 11 months ago
JSON representation
JavaScript library to play sound alerts
- Host: GitHub
- URL: https://github.com/azer/alert
- Owner: azer
- Created: 2013-07-21T22:04:54.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2017-10-07T20:04:30.000Z (over 8 years ago)
- Last Synced: 2024-04-15T03:09:22.240Z (about 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 109 KB
- Stars: 111
- Watchers: 5
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## alert
JavaScript library to play sound alerts
```js
alert = require('alert')
alert() // Plays default alert "bottle"
alert('purr')
alert.volume(0.5)
```
See `content.js` for all available sounds.
Try it at
* [requirebin](http://requirebin.com/?gist=6050220)
* [jsbin](http://jsbin.com/enobox/1/edit)
## Install
```bash
$ npm install alert
```
## Manual
### Available Sounds
* bottle (default)
* glass
* funk
* morse
* purr
* tink
* submarine
### Adding Custom Sounds
```js
alert.content['foo'] = ['http://bar.com/foo.mp3', 'http://bar.com/foo.ogg']
alert('foo')
```
## 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/azer/alert/master/dist/alert.js
```
And include it on your page:
```html
playAlert('purr')
```
### Accessing Audio API
```js
alert.player.src()
// => foobar.mp3
alert.player.on('ended', function(){})
```
More info is at [azer/play-audio](http://github.com/azer/play-audio)