예제 #1
0
 private void PreScanFile(Stream stream)
 {
     while (_frameInfoCollection.AddFromMP3Stream(stream))
     {
         ;
     }
 }
예제 #2
0
        private void ParseForMP3Frame(Stream stream)
        {
            if (_parsedStream)
            {
                return;
            }

            MP3Frame frame = null;
            long     offsetOfFirstFrame = 0;

            while (frame == null && !stream.IsEndOfStream())
            {
                offsetOfFirstFrame = stream.Position;
                frame = MP3Frame.FromStream(stream);
            }

            if (frame == null)
            {
                throw new MP3Exception("Could not find any MP3-Frames in the stream.");
            }

            XingHeader xingHeader = XingHeader.FromFrame(frame);

            if (xingHeader != null)
            {
                offsetOfFirstFrame = stream.Position;
            }

            _inputFormat = new MP3Format(frame.SampleRate, frame.ChannelCount, frame.FrameLength, frame.BitRate); //implement VBR?

            //Prescan stream
            _frameInfoCollection = new FrameInfoCollection();
            while (_frameInfoCollection.AddFromMP3Stream(stream))
            {
                ;
            }

            stream.Position = offsetOfFirstFrame;

            _parsedStream = true;
        }