Esempio n. 1
0
        private static void TestTagUtilsTestCloneUsingRaw()
        {
            ID3.Tag tag = TestTags.CreateDemoTag(Version.v2_3);

            byte[] b0 = TagUtils.TagToRaw(tag);
            byte[] b1 = TagUtils.TagToRaw(tag.Clone());

            UnitTest.Test(ArrayUtils.IsEqual(b0, b1));
        }
Esempio n. 2
0
        private void ProcessFileForAdd(string fileName, HashSet <string> filenamesCaseInsensitive)
        {
            if (filenamesCaseInsensitive.Contains(fileName))
            {
                return;
            }

            try
            {
                ID3.Tag tag = ID3.TagUtils.ReadTag(new FileInfo(fileName));

                if (!Object.ReferenceEquals(tag, null))
                {
                    ID3.TagEditor editor = new ID3.TagEditor(tag);

                    int bitrate = -1;
                    if (!Object.ReferenceEquals(tag, null))
                    {
                        try
                        {
                            int tagSize = TagUtils.TagSizeV2(new FileInfo(fileName));
                            using (Stream stream = VirtualDrive.OpenInStream(fileName))
                            {
                                stream.Seek(tagSize, SeekOrigin.Begin);
                                bitrate = ID3MediaFileHeader.MP3Header.ReadBitrate(
                                    stream, VirtualDrive.FileLength(fileName));
                            }
                        }
                        catch (Exception)
                        {
                            bitrate = -1;
                        }
                    }

                    var track = new Tracks();

                    track.ID          = Guid.NewGuid();
                    track.Artist      = ShrinkText(editor.Artist, 64);
                    track.Title       = ShrinkText(editor.Title, 64);
                    track.Album       = ShrinkText(editor.Album, 64);
                    track.Filename    = ShrinkText(fileName, 1024);
                    track.ReleaseYear = ShrinkText(editor.ReleaseYear, 10);
                    track.TrackNumber = ShrinkText(editor.TrackNumber, 10);
                    track.PartOfSet   = ShrinkText(editor.PartOfSet, 10);
                    track.ContentType = ShrinkText(editor.ContentType, 64);
                    track.FullText    = ShrinkText(track.Artist + track.Title + track.Album + track.ContentType, 256);
                    track.Bitrate     = ShrinkText(bitrate.ToString(), 10);

                    databaseChanger.AddTrack(track);
                }
            }
            catch (Exception)
            {
            }
        }