TooTallNate / node-speaker

Output PCM audio data to the speakers
649 stars 145 forks source link

can only play music one time after the node.js script has started. #30

Closed yrielectro closed 10 years ago

yrielectro commented 10 years ago
var Speaker = require('speaker'), fs = require('fs'), lame = require('lame');

playSong('closedoor.mp3'); //this function works only one time each runtime 

function playSong(song) {
        console.log("MUSIC START");
        var readStream = fs.createReadStream('/home/pi/moteino/' + song);
        $stream = readStream.pipe(new lame.Decoder())
          .on('format', function (format) {
            this.pipe(new Speaker(format));
          });

        $stream.on('close', function()
        { 
            console.log("MUSIC DONE"); //"MUSIC DONE" never gets printed to the console.
        });
}

I get a error message in my console:

node: /home/pi/.node-gyp/0.10.12/src/node_buffer.h:76: static char* node::Buffer::Data(v8::Handlev8::Value): Assertion `val->IsObject()' failed.

TooTallNate commented 10 years ago

I can't seem to reproduce your assertion error. Perhaps try upgrading to the latest node version? Let me know if you're still having issues.