How to loop an MP3?
I use this to play an MP3, but it only plays once.
I want to play the MP3 continuously.
/*jslint node: true, vars: true, maxerr: 50, indent: 4 */
(function (console, require, alarm) {
"use strict";
var fs = require("fs");
var lame = require("lame");
var Speaker = require("speaker");
function start() {
var stream = fs.createReadStream("sounds/alarm.mp3");
stream.pipe(new lame.Decoder()).pipe(new Speaker());
}
alarm.start = start;
}(global.console, require, exports));
Using:
- node-lame: https://github.com/TooTallNate/node-lame
- node-speaker: https://github.com/TooTallNate/node-speaker