Open teegh opened 9 years ago
+1
:+1:
+1 +1 +1
+1
+1
+1
+1 I am hitting this on Mac El Capitan 10.11.1
+1
+1
+1 😢
I tackling this problem after a while. In order to avoid the error, it turned out that you had better stop music playing yourself.
For example, The follow is a simple code. Perhaps I think it is important to call decoder.unpipe()
and bufferStream.end()
themselves.
const lame = require('lame')
const Speaker = require('speaker')
const stream = require("stream")
let sound_duration = 3*60*1000 // e.g. 3 minutes song
setTimeout( () => {
bufferStream = new stream.PassThrough()
decoder = new lame.Decoder()
speaker = new Speaker()
bufferStream.end( SOUND_DATA_BUFFER )
bufferStream.pipe( decoder )
.on("error", () => { /*doSomething*/ })
.on("close", () => { /*doSomething*/ })
.on("unpipe", () => { /*doSomething*/ })
.on("end", () => { /*doSomething*/ })
.pipe(speaker)
.on("finish", () => { /*doSomething*/ })
}, 500)
// Forcibly stop music right before the end of performance
setTimeout( () => {
setTimeout( () => { console.log("bufferStream pause"); bufferStream.pause()}, 500)
setTimeout( () => { console.log("bufferStream unpipe"); bufferStream.unpipe()}, 1000)
setTimeout( () => { console.log("decoder unpipe"); decoder.unpipe()}, 1500)
setTimeout( () => { console.log("bufferStream end"); bufferStream.end()}, 2000)
setTimeout( () => { console.log("speaker end"); speaker.close()}, 2500)
setTimeout( () => { console.log("--- play next ---"); }, 3000)
} , sound_duration - 2500)
Hi, I am very grateful to node-speaker. I have some questions. When repeatedly play music, error occurs occasionally in Mac OSX. (It does not occur in linux.) The error occurs in the following. Is this a problem of xcode? Or will the problem of node-speaker? Please give me some advice.
https://github.com/teegh/speakerErrorCase
./node_modules/speaker/index.js 353
Error occurs in the above codes. Error message was following.