multi-mpg123
v0.1.1
Published
A Node.js wrapper to play MP3 files using the mpg123 command line tool.
Downloads
7
Readme
multi-mpg123
MPG123player is a Node.js package that provides an interface to play, control, and manage MP3 playback using the mpg123
command-line tool. This package allows you to easily integrate MP3 playback capabilities into your Node.js applications.
It allows to play multiple files at once! Which is nice when you don't want to stop the previous started sound harshly just because you want to play a new one.
Features
- Play MP3 files
- Layering Sounds - play multiple files at once!
- Pause and resume playback
- Stop playback
- Adjust playback volume
- Option to loop file
Installation
Ensure you have mpg123
installed on your system. For most Unix systems, you can install it via your package manager:
# Ubuntu/Debian
sudo apt-get install mpg123
# macOS
brew install mpg123
To install MPG123player via npm, run:
npm install multi-mpg123
Usage
Here's how to integrate and use MPG123player in your Node.js application:
Playing an MP3 File
import MPG123player from 'multi-mpg123';
const mpg123 = new MPG123player();
// Play an MP3 file
const { pause, stop, volume } = await mpg123.play({
file: 'path/to/file.mp3',
options: { loop: false }
});
// Control playback
pause(); // Pause playback
stop(); // Stop playback
volume(50); // Set volume to 50%
or
import MPG123player from 'mpg123player';
const mpg123 = new MPG123player();
// Play an MP3 file
const { id } = await mpg123.play({
file: 'path/to/file.mp3',
options: { loop: false }
});
// Control playback
mpg123.pause(id); // Pause playback
mpg123.stop(id); // Stop playback
mpg123.volume(id, 50); // Set volume to 50%
Contributing
Contributions to the MPG123player are welcome. Please ensure that your contributions adhere to the project's coding standards and include appropriate tests.
License
This project is licensed under the MIT License - see the LICENSE file for details.