cli-sound is a Node.js utility designed for playing audio files from command-line applications and other Node.js environments. As of version 1.1.3, it offers robust cross-platform compatibility by leveraging various locally installed, headless audio programs such as `ffplay`, `mpv`, or `mpg123`. It differentiates itself from similar packages like `play-sound` through enhanced reliability, native TypeScript types, comprehensive ESM and CommonJS support, and advanced features such as volume control and customizable audio player commands. The package operates by executing a compatible audio program found on the system via `node:child_process.exec`, automatically detecting the first available player from a predefined list. Its current release cadence appears stable, with a focus on incremental improvements and broad system compatibility.
npm install cli-soundVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to create a Player instance, configure it with options like volume, and play an audio file. Includes error handling for common issues like missing players.
Ensure you have a suitable command-line audio player installed and accessible via your system's PATH. Popular choices include `ffmpeg` (which includes `ffplay`) or `mpv`.
Consult the `cli-sound` documentation or test with different players to determine volume control compatibility. For critical volume control, ensure you are using a player known to support it (e.g., `ffplay`, `mpv`).
When using the `commands` or `extendCommands` options with user-supplied data, rigorously sanitize all inputs to prevent malicious command execution. Avoid direct concatenation of untrusted strings.
Install a compatible audio player like `ffmpeg` (which includes `ffplay`) or `mpv` via your operating system's package manager (e.g., `sudo apt install ffmpeg` on Debian/Ubuntu, `brew install ffmpeg` on macOS, or download binaries for Windows).
Verify that the audio player executable is correctly installed and its directory is included in your system's PATH. Try running the player manually from your terminal (e.g., `ffplay --version`). Reinstall the player if necessary.
Check the integrity and format of your audio file. Try playing the same audio file directly with the detected player from your terminal to get more specific error messages from the audio player itself. Ensure the file path is correct and accessible.
No dependency data recorded yet.