NodeJS basedRadio (without ShoutCast)

I like to create a radio station that is based on NodeJS without using ShoutCast.

NodeJS-based playlist

Currently, I managed to transfer the audio file to the browser, but I donโ€™t know how to create a server-side playlist that constantly โ€œplaysโ€ the current song and restarts it after the end has been reached.

thats my current approach:

'use strict'; var http = require('http'); var fs = require('fs'); var mm = require('musicmetadata'); var ID3 = require('id3'); var express = require('express'); var app = express(); var stream; function startPlaylist() { stream = fs.createReadStream(__dirname + '/AnsolasChill_loop.mp3', { start: 0 }); //10130000 /* * Start serverside "Playback" here. * Restart Playlist once the end of the song has been reached */ } startPlaylist(); // Start Server Side Playlist once the Server starts. app.get('/', function(req, res) { /* * get current playback postion of playlist * start stream from current playback position */ res.setHeader('Content-Type', 'audio/mpeg'); stream.pipe(res); // Events stream.on('data', function(chunk) { console.log('data: got %d bytes of data', chunk.length); }) stream.on('end', function() { console.log('there will be no more data.'); stream = null; stream = fs.createReadStream(__dirname + '/AnsolasChill_loop.mp3', { start: 0 }); }); stream.on('readable', function() { var chunk; while (null !== (chunk = stream.read())) { //console.log(i,' readable:', chunk.length); } }); }); app.listen(3000); 

[edit]

VLC as a playlist?

Just found this topic: Related: Is there a good radio-like streaming audio solution for node.js?

Brad told me that he uses VLC as the source for his radio on node.

So, I assume that it outputs the output from the VLC to Node? How to work with metadata? Is there any way to get them from VLC? Or at least can I get the current song id or some other way to determine the current song? An example will be very enjoyable.


Any constructive help is appreciated :)

+2
source share

Source: https://habr.com/ru/post/949051/


All Articles