yaquza yaquza

yaquza yaquza

  • NA
  • 13
  • 13.7k

Read & Play a Sound file

Jan 25 2012 3:15 AM
Hi

I want Read and play a sound file in c# as byte by byte. this bytes that reading, place in array of byte by lengh 500000. Now i want play this array! Please help me.

System.IO.FileStream fs = new System.IO.FileStream(@"c:\a.wav", System.IO.FileMode.Open);

byte[] buffer = new byte[500000];

byte[] buffer = new byte[500000];
fs.Read(buffer, 0, buffer.Length);

system.IO.Stream s = new system.IO.MemoryStream(buffer);
System.Media.SoundPlayer spPlayer = new System.Media.SoundPlayer(s);
spPlayer.Stream = s;
spPlayer.Stream.Position = 0;

spPlayer.Play();

Please Help what is Problem of my code?

Answers (2)