Playing an mp3 Byte[] Array how?  
Author Message
Madok





PostPosted: Visual C# General, Playing an mp3 Byte[] Array how? Top

I have stored in memmory an byte array of an mp3 file and i want to play it how can i do this


Visual C#8  
 
 
ahmedilyas





PostPosted: Visual C# General, Playing an mp3 Byte[] Array how? Top

well you can store the byte array into a memorystream, then play it. The thing is in .NET 2.0 there is no direct way of playing an MP3 file. You would have to use some external software or something to do this.

question is - why did you store it in a byte[] array



 
 
Madok





PostPosted: Visual C# General, Playing an mp3 Byte[] Array how? Top

Because i would have just recieved the mp3 file from a Socket stream or any other form of stream

 
 
ahmedilyas





PostPosted: Visual C# General, Playing an mp3 Byte[] Array how? Top

well one way would be to write it to disk, then play it in either an embedded WMP component or launch a process on the mp3 file. Example:

System.Diagnostics.Process.Start("filename.mp3");



 
 
Madok





PostPosted: Visual C# General, Playing an mp3 Byte[] Array how? Top

i want it to be a streaming like last.fm

 
 
ahmedilyas





PostPosted: Visual C# General, Playing an mp3 Byte[] Array how? Top

I believe that would be using Windows Media Streaming/Encoding technologies (asx/ other Windows Media streaming formats) you can't quite stream an mp3/wave file over the network, perhaps there is a way but certainly it will need to be downloaded and played since everything or rather the info is held in the header and the rest of the file is full of data and when played, it looks at the header and plays the file accordingly. sending it in chunks would cause it not to play and be an invalid file.



 
 
Madok





PostPosted: Visual C# General, Playing an mp3 Byte[] Array how? Top

ok one the streaming of mp3's your just WRONG! many technologies stream mp3 such as Shoutcast plus have you ever played a partially downloaded mp3 ANSWER: yes!

plus if you had done your research before coming you would have known that only the ID3 tag if implemented is stored in the header and that only holds information that is not needed to play mp3 data stream but you are partially right about the header information but mp3 files consist of mp3 frames that contain all the necessary information to do with unencoding the data

http://upload.wikimedia.org/wikipedia/en/e/ee/Mp3filestructure.jpg



 
 
ahmedilyas





PostPosted: Visual C# General, Playing an mp3 Byte[] Array how? Top

:-) I was not sure but just one theory