nodeshout-napi
Native libshout bindings for node.js.
Libshout allows applications to easily communicate and broadcast to an Icecast streaming media server. It handles the socket connections, metadata communication, and data streaming for the calling application, and lets developers focus on feature sets instead of implementation details.
More detail: http://icecast.org
Original libshout docs: http://www.aelius.com/njh/libshout-doc/libshout.html (a copy of this page can be also found at /docs/libshout2.html
)
Node version compatibility
This fork supports newer versions of Node as well as older one.
This fork supports all major OS, including Windows, macOS and Linux.
Usage
You have to install libshout library before using nodeshout. If you work on Windows, you'll need the libshout dll.
yum install libshout
apt-get install libshout
brew install libshout
Then, install nodeshout via npm.
npm i nodeshout-napi
Initalize nodeshout library, create a Shout
instance and configure it.
const nodeshout = ;// Initalizenodeshout; // Create a shout instanceconst shout = nodeshout; // Configure itshout;shout;shout;shout;shout;shout; // 0=ogg, 1=mp3shout;shout;shout;
Open the connection.
if shout !== nodeshoutErrorTypesSUCCESS throw 0;
If connection is successful, above function will return nodeshout.ErrorTypes.SUCCESS
which is integer 0
. After successful connection, you can send audio file chunks via shout.send
method.
shout;
For the synchronization, there is 2 method provided. First one is shout.sync()
method, this method blocks current thread. Second one is shout.delay()
method, this method returns how many milliseconds you should wait to send next audio chunk.
Metadata
// Create a metadata instanceconst metadata = nodeshout; // Set currently playing song.metadata; // Apply metadata to shoutshout;
Streams
Helper streams make all the things super-easy. You don't have to deal with reading and syncing stuff. They're avaliable >= 0.1.1
.
Include helper stream classes.
const FileReadStream ShoutStream = ;
and then pipe them together. That's all!
const fileStream = './some/music.mp3' 65536;const shoutStream = fileStream; shoutStream;
Example
Check the /demos
folder.