Beispiel #1
0
 private void CreateTableOfContents()
 {
     try
     {
         this.tableOfContents = new List <Mp3Index>((int)(this.mp3DataLength / 400L));
         Mp3Frame mp3Frame;
         do
         {
             Mp3Index mp3Index = new Mp3Index();
             mp3Index.FilePosition   = this.mp3Stream.Position;
             mp3Index.SamplePosition = this.totalSamples;
             mp3Frame = this.ReadNextFrame(false);
             if (mp3Frame != null)
             {
                 this.ValidateFrameFormat(mp3Frame);
                 this.totalSamples   += (long)mp3Frame.SampleCount;
                 mp3Index.SampleCount = mp3Frame.SampleCount;
                 mp3Index.ByteCount   = (int)(this.mp3Stream.Position - mp3Index.FilePosition);
                 this.tableOfContents.Add(mp3Index);
             }
         }while (mp3Frame != null);
     }
     catch (EndOfStreamException)
     {
     }
 }
Beispiel #2
0
        private void CreateTableOfContents()
        {
            try
            {
                // Just a guess at how many entries we'll need so the internal array need not resize very much
                // 400 bytes per frame is probably a good enough approximation.
                tableOfContents = new List <Mp3Index>((int)(mp3DataLength / 400));
                Mp3Frame frame = null;
                do
                {
                    var index = new Mp3Index();
                    index.FilePosition   = mp3Stream.Position;
                    index.SamplePosition = totalSamples;
                    frame = ReadNextFrame(false);
                    if (frame != null)
                    {
                        ValidateFrameFormat(frame);

                        totalSamples     += frame.SampleCount;
                        index.SampleCount = frame.SampleCount;
                        index.ByteCount   = (int)(mp3Stream.Position - index.FilePosition);
                        tableOfContents.Add(index);
                    }
                } while (frame != null);
            }
            catch (EndOfStreamException)
            {
                // not necessarily a problem
            }
        }
Beispiel #3
0
        private void CreateTableOfContents()
        {
            try
            {
                // Just a guess at how many entries we'll need so the internal array need not resize very much
                // 400 bytes per frame is probably a good enough approximation.
                tableOfContents = new List<Mp3Index>((int)(mp3DataLength / 400));
                Mp3Frame frame = null;
                do
                {
                    var index = new Mp3Index();
                    index.FilePosition = mp3Stream.Position;
                    index.SamplePosition = totalSamples;
                    frame = ReadNextFrame(false);
                    if (frame != null)
                    {
                        ValidateFrameFormat(frame);

                        totalSamples += frame.SampleCount;
                        index.SampleCount = frame.SampleCount;
                        index.ByteCount = (int)(mp3Stream.Position - index.FilePosition);
                        tableOfContents.Add(index);
                    }
                } while (frame != null);
            }
            catch (EndOfStreamException)
            {
                // not necessarily a problem
            }
        }