I have a server that sends data via a socket, the data is a wav ‘file’. I can easily write the data to disk and then play it in WMP, but I have no idea how I can play it as I read it from the socket. Is it possible?
Bonus question: how would I do it if the stream was in mp3 or other format?
This is for windows in native C++.
Because you’ve said WMP, I’m assuming the question applies to trying to play a wav file on a windows machine. If not, this answer isn’t relevant.
What you want to do isn’t trivial. There is a good article here on code project that describes the windows audio model. It describes how to set up the audio device and how to stream data into the device for playback. You ‘simply’ need to supply data coming in from your socket as data for the playback buffers. But that’s where all of the tricky work is. You have to be sure that
It’s an interesting exercise. But tricky.