Last active
January 28, 2018 02:34
-
-
Save ollelauribostrom/eceda29de8923083827641ed1a7a5154 to your computer and use it in GitHub Desktop.
Play MP3-stream from Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import request from 'request'; | |
import Speaker from 'speaker'; | |
import lame from 'lame'; | |
const speaker = new Speaker({ | |
channels: 2, | |
bitDepth: 16, | |
sampleRate: 44100, | |
mode: lame.STEREO, | |
}); | |
const decoder = new lame.Decoder(); | |
export default function (streamUrl) { | |
request.get(streamUrl).pipe(decoder).pipe(speaker); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment