# play-sound

> Play audio files by shelling out to available audio tool.

Latest version **1.1.6** (published 2023-08-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install play-sound
pnpm add play-sound
yarn add play-sound
bun add play-sound
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.6 |
| Published | 2023-08-24 |
| First published | 2014-09-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/play-sound) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 222 |
| Author | Hrvoje Simic |
| Maintainers | justinjmoses, shime |
| Keywords | audio, sound, play |

## Links

- npm: https://www.npmjs.com/package/play-sound
- Repository: https://github.com/shime/play-sound
- Issues: https://github.com/shime/play-sound/issues
- npm.io page: https://npm.io/package/play-sound

## Dependencies (1)

- [find-exec](https://npm.io/package/find-exec.md) 1.0.3

## Alternatives

- [@snazzah/davey](https://npm.io/package/@snazzah/davey.md) — 1.5M weekly downloads
- [@vendure/testing](https://npm.io/package/@vendure/testing.md) — 8.3K weekly downloads
- [vue-simple-context-menu](https://npm.io/package/vue-simple-context-menu.md) — 6.6K weekly downloads
- [cypress-webpack-preprocessor-v5](https://npm.io/package/cypress-webpack-preprocessor-v5.md) — 2.1K weekly downloads
- [@backstage/plugin-catalog-backend-module-puppetdb](https://npm.io/package/@backstage/plugin-catalog-backend-module-puppetdb.md) — 1.3K weekly downloads

## Recent versions

- 1.1.6 (latest) — 2023-08-24
- 1.1.5 — 2022-01-08
- 1.1.4 — 2022-01-04
- 1.1.3 — 2018-12-19
- 1.1.2 — 2017-12-13
- 1.1.1 — 2016-10-22
- 1.1.0 — 2016-10-22
- 1.0.0 — 2016-10-10
- 0.0.9 — 2016-04-20
- 0.0.8 — 2016-04-13
- 0.0.7 — 2015-10-21
- 0.0.6 — 2015-10-11
- 0.0.5 — 2015-03-16
- 0.0.4 — 2015-01-13
- 0.0.3 — 2015-01-12
- … 2 more at https://npm.io/package/play-sound/versions

## README

# play-sound

[![Downloads](https://img.shields.io/npm/dt/play-sound.svg)](https://npmjs.org/package/play-sound)

Play sounds by shelling out to one of the available audio players.

## Installation

    npm install play-sound

## Examples

```javascript
var player = require('play-sound')(opts = {})

// $ mplayer foo.mp3 
player.play('foo.mp3', function(err){
  if (err) throw err
})

// { timeout: 300 } will be passed to child process
player.play('foo.mp3', { timeout: 300 }, function(err){
  if (err) throw err
})

// configure arguments for executable if any
player.play('foo.mp3', { afplay: ['-v', 1 ] /* lower volume for afplay on OSX */ }, function(err){
  if (err) throw err
})

// access the node child_process in case you need to kill it on demand
var audio = player.play('foo.mp3', function(err){
  if (err && !err.killed) throw err
})
audio.kill()
```

## Options

* `players` – List of available audio players to check. Default:
  * [`mplayer`](https://www.mplayerhq.hu/)
  * [`afplay`](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/afplay.1.html)
  * [`mpg123`](http://www.mpg123.de/)
  * [`mpg321`](http://mpg321.sourceforge.net/)
  * [`play`](http://sox.sourceforge.net/)
  * [`omxplayer`](https://github.com/popcornmix/omxplayer)
  * [`aplay`](https://linux.die.net/man/1/aplay)
  * [`cmdmp3`](https://github.com/jimlawless/cmdmp3)
  * [`cvlc`](https://www.commandlinux.com/man-page/man1/cvlc.1.html)
  * [`powershell`](https://docs.microsoft.com/en-us/powershell/)
* `player` – Audio player to use (skips availability checks)

## Prior art

* [play.js](https://github.com/Marak/play.js) - play sound files from node.js to your speakers

## License

MIT

---
_Source: https://npm.io/package/play-sound · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
