1.1.0 • Published 8 years ago
streamplayer v1.1.0
This is a very simple module to allow playing audio streams via mpg321.
The standard method to play MP3 on nodejs appears to be to use a combination of the excellent lame and speaker modules. There are two reasons why you might prefer to use streamplayer instead:
- streamplayer does not require compilation of lame or mpg321 (only the very simple mkfifo), making it much less likely to break for nodejs changes.
- streamplayer sends events with progress information during playback.
Usage is very simple:
const StreamPlayer = require('streamplayer');
var player = new StreamPlayer();
var mp3_stream = yourFunc();
player.on('end', () => {
console.log('Finished!');
});
player.on('progress', info => {
console.log(`Played ${info.progress}%`);
});
player.play(mp3_stream);