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

fridgefm-radio-core

v3.2.7

Published

internet radio engine made on NodeJS platform

Downloads

5

Readme

Radio engine for NodeJS

build coverage npm GitHub

Usage

Simple lightweight package to start your own live radio station 📻 Just drop your mp3 files and broadcast them to the world 🌎Heavily inspired by Shoutcast and Icecast.

Setup

Installation

npm i @fridgefm/radio-core --save

Server

const { Station } = require('@fridgefm/radio-core');
const station = new Station();

station.addFolder('User/Music');

server.get('/stream', (req, res) => {
  station.connectListener(req, res);
});

station.start();

Client

<audio
    controls
    type='audio/mp3'
    src='/stream'
/>

Station constructor

Creating a station is as simple as

const myAwesomeStation = new Station({
  verbose: false, // if true - enables verbose logging (for debugging purposes),
  responseHeaders: { // in case you want custom response headers for your endpoint
    'icy-genre': 'jazz'
  }
})

Station methods

connectListener connects real users to your station, this is the only method that should be exposed to listeners
response argument is required

station.connectListener(request, response, callback);

addFolder adds track within a folder to the playlist

station.addFolder('User/Music');

start starts broadcasting

station.start();

next instantly switches track to the next one

station.next();

getPlaylist just returns you the entire playlist

station.getPlaylist();

reorderPlaylist lets you manipulate the entire playlist via passed callback

const myShuffleMethod = (list) => list
  // doubles the list (making it twice as long)
  .concat(list)
  // filters out the specific track
  .filter(track => track.fsStats.name !== 'Artist - Track'); 

station.reorderPlaylist(myShuffleMethod);

There are also some built-in shuffle methods

const { SHUFFLE_METHODS } = require('@fridgefm/radio-core')

// This one randomly shuffles the playlist (keeping the length the same)
station.reorderPlaylist(SHUFFLE_METHODS.randomShuffle());

// This one moves the track on the 1st position and moves it to the 2nd position 
station.reorderPlaylist(SHUFFLE_METHODS.rearrange({ from: 1, to: 2 }));

on lets you make a subscription to station events (see below)

Station events

Station emits several events - they are available via

const { PUBLIC_EVENTS } = require('@fridgefm/radio-core')

NEXT_TRACK

event fires when track changes
useful for getting to know when exactly the track changed and what track that is

station.on(PUBLIC_EVENTS.NEXT_TRACK, (track) => {
  const result = await track.getMetaAsync();
  console.log(result)
})

START

Event fires on station start

station.on(PUBLIC_EVENTS.START, () => { console.log('Station started') });

RESTART

Event fires on station restart (when playlist is drained and new one is created)
it might be a nice time to shuffle your playlist for example

station.on(PUBLIC_EVENTS.RESTART, () => { /* do something*/ });

ERROR

Event fires when there is some error. You should add this handler - otherwise any error will be treated as unhandled (causing process.exit depending on Node version)

station.on(PUBLIC_EVENTS.ERROR, (e) => { handleError(e) });

or just go to examples

Development

npm run start

or

npm run start [path/to/your_mp3tracks]
# in this case it would take a little more time, just wait

Demo

Sandbox is available here on Codesandbox
Fully working demo is available on FridgeFM