This project has moved and is read-only. For the latest updates, please go here.

WCF Streaming and NAudio

Oct 22, 2013 at 4:35 PM

I want to use NAudio with WCF streaming. I have a service loading .wav (16 bit PCM: 8kHz 1 channels) files from a server and streaming them to a client. In the service i read in the file as a WaveStream and then return it as a <Stream>.

The client receive this as a <MessageBodyStream>. How do I play this stream on the client using NAudio?


Oct 25, 2013 at 7:18 AM
the BufferedWaveProvider is best for using with streaming. Every time you receive a block of audio over the network, write it into a BufferedWaveProvider. Then you can play from that.
Oct 26, 2013 at 9:50 AM
Thank you!

I think WaveStream is a supported return type over wcf streaming. I have enbedded the WaveStream as MessageBodyMember in a MessageContract. And as you suggest, then I should write the WaveStream to the bufferedWaveProvider on the client side?

..or do I first need to write the WaveStream to a MemoryStream and return it from the wcf service. Then writing the memorystream to BufferedWaveProvider on the client?



Oct 26, 2013 at 10:43 AM
I'd just return byte arrays, and let the client put them into the BufferedWaveProvider. You could also ask on stackoverflow as I don't know what the recommended way to stream media over WCF is.
Oct 27, 2013 at 9:52 PM
WCF has a Streamed binding:

It works very well.
Oct 28, 2013 at 12:03 PM
cool, I'll have to give that a try some time.