This project has moved. For the latest updates, please go here.

WCF Streaming and NAudio

Oct 22, 2013 at 3:35 PM
Hi,

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?

Regards

PONDEV
Coordinator
Oct 25, 2013 at 6: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 8: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?

Regards

Peder


Coordinator
Oct 26, 2013 at 9: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 8:52 PM
WCF has a Streamed binding:

http://stackoverflow.com/questions/13525402/streaming-with-wcf-and-mtom

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