public static bool IsDemoTag(TagEditor editor) { return(editor.Album == "Album" && editor.Artist == "Artist" && editor.Title == "Title" && editor.Comment == "Comment"); }
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) { } }
public static Tag CreateDemoTag(Version v) { Tag tag = TagDescriptionMap.Instance[v].CreateTag(); TagEditor editor = new TagEditor(tag); editor.Artist = "Artist"; editor.Album = "Album"; editor.Title = "Title"; editor.TrackNumber = "1"; editor.Comment = "Comment"; return(tag); }
public static void CreateDemoTags(string path, int count, Action <TagEditor> action) { for (int i = 0; i < count; ++i) { Tag tag = TestTags.CreateDemoTag(ID3.Version.v2_3); TagEditor editor = new TagEditor(tag); editor.Title = "Song No. " + (i + 1); editor.TrackNumber = (i + 1).ToString(); editor.ReleaseYear = "1993"; action(editor); TagUtils.WriteTag(tag, new FileInfo(Path.Combine(path, "Test" + i + ".mp3"))); } }
private static void TestTagUtilsBuildByCodeAndSerializeInVirtualStore() { foreach (ID3.Version version in ID3.Version.Versions) { string filename = VirtualDrive.VirtualFileName( "TestID3TagBuildByCodeAndSerializeInVirtualStore\\" + version.ToString() + ".tag"); Tag tag0 = TestTags.CreateDemoTag(version); TagUtils.WriteTag(tag0, new FileInfo(filename)); Tag tag1 = TagUtils.ReadTag(new FileInfo(filename)); TagEditor editor0 = new TagEditor(tag0); TagEditor editor1 = new TagEditor(tag1); UnitTest.Test(editor1.Equals(editor0)); } }