npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nodeshout-napi

v1.1.1

Published

Native libshout bindings for node.

Downloads

12

Readme

nodeshout-napi

NPM

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 = require("nodeshout-napi");
// Initalize
nodeshout.init();

// Create a shout instance
const shout = nodeshout.create();

// Configure it
shout.setHost('localhost');
shout.setPort(8000);
shout.setUser('source');
shout.setPassword('password');
shout.setMount('mount');
shout.setFormat(1); // 0=ogg, 1=mp3
shout.setAudioInfo('bitrate', '192');
shout.setAudioInfo('samplerate', '44100');
shout.setAudioInfo('channels', '2');

Open the connection.

if (shout.open() !== nodeshout.ErrorTypes.SUCCESS)
    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.send(buffer, bytesRead);

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 instance
const metadata = nodeshout.createMetadata();

// Set currently playing song.
metadata.add('song', 'Led Zeppelin - I can\'t quit you baby');

// Apply metadata to shout
shout.setMetadata(metadata);

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 } = require('nodeshout-napi');

and then pipe them together. That's all!

const fileStream = new FileReadStream('./some/music.mp3', 65536);
const shoutStream = fileStream.pipe(new ShoutStream(shout));

shoutStream.on('finish', () => {
    // Finished playing, you can create
    // another stream for next song
});

Example

Check the /demos folder.