Skip to content

StoneCypher/porta_audio

Repository files navigation

porta_audio v0.1.0

Version 0.1.0 was built on 2/28/2026, 4:38:16 AM 1772282296303 from hash fa5216c.

Portable, convenient audio playback for Node.

 

How?

npm install --save-dev porta_audio

From your module app:

import { play } from 'porta_audio';
play('./your.mp3');

From your commonjs app:

const pa = require('porta_audio');
pa.play('./your.wav');

From the CLI:

npx porta_audio alert.wav

Or inline:

node -e "require('porta_audio').play('example.mp3')"

 

API

play(filePath: string): ChildProcess

Plays an audio file using the native player for the current OS. Returns the spawned child process, which you can use to detect when playback finishes.

import { play } from 'porta_audio';

// Fire and forget
play('notification.mp3');

// Wait for playback to finish
const child = play('alert.wav');
child.on('close', (code) => {
  console.log(`done, exit code ${code}`);
  // => done, exit code 0
});

Throws an Error if the current platform is not supported.

 

Platform support

Platform Player Formats
macOS afplay wav, mp3, aac, and most formats
Linux ffplay (preferred) or aplay (fallback) wav, mp3 via ffplay; wav only via aplay
Windows PowerShell Media.SoundPlayer wav

Unsupported platforms (aix, android, freebsd, openbsd, sunos) and unrecognized platforms throw a descriptive error at call time.

 

CLI usage

porta_audio <path-to-audio-file>

Plays a single audio file from the command line. Exits with code 1 and prints usage if called with the wrong number of arguments.

About

Portable, convenient audio playback for Node

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors