c# - How to play multiple wav files at the same time with no delay -


I have a server that has some wav files, and when the client connects it, they play with each of them on the server. You can say for example, when several clients are connected, or when a client requests the same WAV file twice before the completion, I have to play again in parallel.

SoundPlayer I tried the WindowsMediaPlayer object while running it in the following manner:

  WindowsMediaPlayer wmp = new WindowsMediaPlayer (); Wmp.URL = sounds_folder;   

It starts with a delay.

Does anyone know how to do this? Or can there be a way to load buffers with the media player in the initialization so that the game is fast?

I would say that you are using the wrong API. Media player is designed to render media files (consumer media) for small direct samples / clips

Google showed me

http://www.eggheadcafe.com /articles/20030302.asp

The second also assumes that you load the whole sample in-memory upfront, so there is no need to worry about the buffering bar :)

Next: on parallel sounds; You should try other APIs. You may be in luck with them, otherwise use the thread pool in any way

ThreadPool.QueueUserWorkItem Rep. BjinneWok (...)

Manually create a new one Thread () ... and start () that beware of the loss of threading (do no work and of course do not share the data without locking between threads) but for a simple 'fire and error' background sound All this will be easy (provided you have buffers Keep long-term data with sound - that is, make them stable)

Comments