openairplay / node_airtunes

node.js AirTunes v2 implementation: stream wirelessly to Apple audio devices.
BSD 2-Clause "Simplified" License
273 stars 84 forks source link

How to change stream? #18

Closed matthiasleitner closed 10 years ago

matthiasleitner commented 10 years ago

I am trying to use airtunes similar to the example using ffmpeg.

Everything works fine but as soon as I want to switch to another music file I am trying to stop ffmpeg using ffmpeg.kill() on the childProcess ass soon as the devices have stopped. I always get the following error as soon as I call ffmpeg.stdout.pipe airtunes on the new instance of ffmpeg:

Error: Cannot write in buffer after closing it at CircularBuffer.write (../node_modules/airtunes/lib/circular_buffer.js:32:11) at AirTunes.write (../node_modules/airtunes/lib/index.js:63:25)

How can I recreate the buffer properly after the devices have been stopped? Would i be possible to change the stream without stopping the devices?

lperrin commented 10 years ago

I don't have my computer with me right now, but you can try to pass {end: false} to pipe to prevent it from closing the output stream.

I'll look in detail when I come back.

— Sent from Mailbox for iPhone

On Sun, Dec 15, 2013 at 5:22 PM, matthiasleitner notifications@github.com wrote:

I am trying to use airtunes similar to the example using ffmpeg. Everything works fine but as soon as I want to switch to another music file I am trying to stop ffmpeg using ffmpeg.kill() on the childProcess ass soon as the devices have stopped. I always get the following error as soon as I call ffmpeg.stdout.pipe airtunes on the new instance of ffmpeg: Error: Cannot write in buffer after closing it at CircularBuffer.write (../node_modules/airtunes/lib/circular_buffer.js:32:11) at AirTunes.write (../node_modules/airtunes/lib/index.js:63:25)

How can I recreate the buffer properly after the devices have been stopped? Would i be possible to change the stream without stopping the devices?

Reply to this email directly or view it on GitHub: https://github.com/lperrin/node_airtunes/issues/18

matthiasleitner commented 10 years ago

Thanks for your quick response - this helped!

After stoping the "ready" event is fired twice but I can handle this.

lperrin commented 10 years ago

Did you call stream.unpipe after closing it ? It may explain why you get the event twice.

matthiasleitner commented 10 years ago

So I need to call unpipe? I haven't used it by now