Exemple #1
0
        private TagData getID3Tags(FileInfo fi)
        {
            ContainerFactory fac = new ContainerFactory();
            var stream = fi.OpenRead();
            MP3Data data;
            try
            {
                data = fac.Create(stream);
                if (data == null) return null;
                var outStream = new MemoryStream();
                var writer = new ID3V23TagWriter(outStream);
                writer.WriteFrame(data.Frames);

                TagData tags = new TagData();
                tags.ContentLength = stream.Length - 128 - outStream.Length;
                outStream.Seek(0, SeekOrigin.Begin);
                tags.Begin = outStream.ToArray();

                return tags;
            }
            catch (Exception e)
            {
                return null;
            }
        }
Exemple #2
0
        public TagFakeStream(TagData data)
        {
            _data = data;
            // create memoryStream from Begin
            DataAtBegin = new MemoryStream(_data.Begin);
            DataAtEnd = new MemoryStream(_data.End);

            _length = DataAtBegin.Length + DataAtEnd.Length + _data.ContentLength;
        }
        public void ShouldReadAsOne()
        {
            var data = new TagData();
            data.ContentLength = 1;
            data.Begin = arrayByLength(1, 1);
            data.End = arrayByLength(3, 1);

            var stream = new TagFakeStream(data);

            byte[] result = new byte[3];
            stream.Read(result, 0, 3);

            compareStreams(result, 1, 0, 3);
        }
        public void MultipleSeekShouldNotChangeResult()
        {
            var data = new TagData();
            data.ContentLength = 1;
            data.Begin = arrayByValue(0,1,2,3,4);
            data.End = arrayByValue(5,6,7,8,9);
            var stream = new TagFakeStream(data);

            // lies erst 3
            // seek in den nächsten bereich
            // lies
            // lies nochmal
            var result = new byte[2];
            stream.Seek(3, SeekOrigin.Begin);
            stream.Read(result, 0, 2);
            compareStreams(result, 3, 4);

            result = new byte[3];
            stream.Seek(3, SeekOrigin.Begin);
            stream.Read(result, 0, 3);
            compareStreams(result, 3, 4, 0);
        }