How to create a queue of streaming audio in real time?

So, I’m thinking about creating a node application in which users can add songs to the “queue” and transfer songs to all users in real time, but after inspection I’m not quite sure how to do this.

The main article I read was as follows: http://pedromtavares.wordpress.com/2012/12/28/streaming-audio-on-the-web-with-nodejs/

It seems that the icecast server might work very well for this, but is there a way for node to move the songs to the queue that the icecast server will play? As I understand it, the only way to manage the played songs is to specify a playlist or add songs manually, and also tell the server that it does not play anything when there are no songs in the queue, also seems to be a potential problem.

+4
source share
1 answer

I recently worked on a similar project. My solution was to use nodeshout (node ​​binding for libshout) to send audio data from Node to Icecast.

. :

function playSong(){
    // Choose next song
    const nextSong = "./song.mp3";
    const fileStream = new FileReadStream(nextSong, 65536);
    const shoutStream = fileStream.pipe(new ShoutStream(shout));

    shoutStream.on('finish',playSong);
}

playSong()

.

. icecast.xml ~ 30 . , , , - , " ", ( ).

Gist : https://gist.github.com/Cretezy/3623fecb1418e21b5d1f77db50fc7e07

+2

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


All Articles