Click here to Skip to main content
15,916,949 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want read a sound file byte by byte and save in array.then read 2000 byte of file, I want play the 2000 byte that is in array.How do it?
Posted
Comments
Sergey Alexandrovich Kryukov 23-Jan-12 3:56am    
Why byte-by-byte? Why 2000? How about 2024? :-)
Sound file is not played by bytes, by the way, the question makes little sense.
--SA

1 solution

Why? It is unlikely that a short byte stream will contain anything like a real sound sample.

You can do it: convert the bytes to a stream, and feed that to sound player. But I don't know if it will work with a random short segment of a MP3 file - I suspect not.
C#
using (Stream s = new MemoryStream(bytes))
   {
   System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer(s);
   myPlayer.Play();
   }
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 23-Jan-12 3:56am    
Exactly! A 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900