Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nomadhoc/sound-play
An native audio player for NodeJS.
https://github.com/nomadhoc/sound-play
Last synced: about 2 hours ago
JSON representation
An native audio player for NodeJS.
- Host: GitHub
- URL: https://github.com/nomadhoc/sound-play
- Owner: nomadhoc
- License: mit
- Created: 2019-10-23T05:36:30.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-11T03:32:14.000Z (about 1 year ago)
- Last Synced: 2024-10-02T07:29:08.188Z (5 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/sound-play
- Size: 1.03 MB
- Stars: 94
- Watchers: 4
- Forks: 15
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sound-play
_Dead simple sound player for Node -- because it should be simple._
```javascript
const sound = require("sound-play");
sound.play("file.mp3");
```
- Native solution. Does not require third-party application to work on `Windows` and `MacOS`.- Support `.wav`, `.mp3` and other extensions.
# Install
```
npm install sound-play
``````
yarn add sound-play
```# Examples
### Relative path
```javascript
sound.play("file.mp3");
```or
```javascript
const path = require("path");
const filePath = path.join(__dirname, "file.mp3");
sound.play(filePath);
```### Adjusting Volume
```javascript
/**
* 0 = silent
* 0.5 = default
* 1 = max volume
*/
volume = 0.1;
sound.play("file.mp3", volume);
```### Absolute path
```javascript
sound.play("C:\\file.mp3");
```### Promise
```javascript
sound.play("file.mp3").then((response) => console.log("done"));
```### Async/await
```javascript
try {
await sound.play("file.mp3");
console.log("done");
} catch (error) {
console.error(error);
}
```# License
MIT