Exemple #1
0
 private void CopyAudioStream(FileStream writeStream)
 {
     // open original mp3 file stream and seek to the start of the audio
     // or, if the audio's been replaced, create a memorystream from the buffer.
     using (Stream audio = _audio.OpenAudioStream())
     {
         // Copy mp3 stream
         // this will also copy the original ID3v1 tag if present,
         // but it's only 128 bytes extra so it won't matter.
         const int size  = 4096;
         byte[]    bytes = new byte[4096];
         int       numBytes;
         while ((numBytes = audio.Read(bytes, 0, size)) > 0)
         {
             writeStream.Write(bytes, 0, numBytes);
         }
     }
 }