public Album(DirectoryInfo sourceDirectory, IProgress progress, CancellationToken cancellationToken, Session session, Context context) : this(session, context) { var discDirectories = new List<DirectoryInfo>(); discDirectories.Add(sourceDirectory); discDirectories.AddRange(sourceDirectory.GetDirectories()); progress.Begin(discDirectories.Sum(directory => directory.GetFiles("*.mp3").Length)); foreach (var directory in discDirectories) { var disc = new Disc(this, _session, _context); foreach (var file in directory.GetFiles("*.mp3")) { cancellationToken.ThrowIfCancellationRequested(); progress.Advance(file.Name); var track = new Track(file, disc, _session, _context); disc.Tracks.Add(track); } if (disc.Tracks.Count > 0) Discs.Add(disc); } SourceDirectory = sourceDirectory; }
public Track(FileInfo sourceFile, Disc disc, Session session, Context context) : this(session, context) { SourceFile = sourceFile; Disc = disc; // Find tags using (var stream = new BufferedStream(sourceFile.Open(FileMode.Open, FileAccess.Read, FileShare.Read))) { _mpegDataOffset = 0; _mpegDataSize = stream.Length; Stream dataStream; // Better be sorted from outer to inner Type[] tagTypes = { typeof(Id3v2Tag), typeof(Id3v1Tag), typeof(Lyrics3v2Tag), typeof(ApeTag) }; while (true) { dataStream = new SubStream(stream, _mpegDataOffset, _mpegDataSize); var anyTagFound = false; foreach (var tagType in tagTypes) { var tag = (ITag)Activator.CreateInstance(tagType); if (!tag.Read(dataStream)) continue; if (tag.Position == TagPosision.Beginning) { _mpegDataOffset += tag.Size; _mpegDataSize -= tag.Size; } else { _mpegDataSize -= tag.Size; } Tags.Add(tag); anyTagFound = true; break; } if (!anyTagFound) break; } MpegFileInfo = new MpegFileInfo(dataStream); } }
public static void Main() { if (!Settings.Default.Upgraded) { Settings.Default.Upgrade(); Settings.Default.Upgraded = true; } var context = new Context(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm(context)); }
private Disc(Session session, Context context) : this() { _session = session; _context = context; }
public Disc(Album album, Session session, Context context) : this(session, context) { Album = album; }
private Album(Session session, Context context) : this() { _session = session; _context = context; }
private Track(Session session, Context context) : this() { _session = session; _context = context; }
public MainForm(Context context) : this() { _context = context; }