public ID3v1(string path) { this.path = path; using (ID3TagFileStream fs = new ID3TagFileStream(path, FileMode.Open, FileAccess.Read)) { if (!fs.HaveID3v1()) { fs.Close(); isComplete = false; return; } title = fs.ReadText(30); fs.Seek(-95, SeekOrigin.End); artist = fs.ReadText(30); fs.Seek(-65, SeekOrigin.End); album = fs.ReadText(30); fs.Close(); string tempPath = System.IO.Path.GetFileNameWithoutExtension(path); if (title == "" || title == null) { title = tempPath; } if (artist == "" || artist == null) { artist = "Unknown"; } if (album == "" || album == null) { album = "Unknown"; } isComplete = true; } }
public ID3v2(string path) { this.path = path; this.frames = new ArrayList(); this.frames.Add("TPE1"); this.frames.Add("TALB"); this.frames.Add("TIT2"); this.frameIDs = new Hashtable(); this.frameIDs.Add("TP1", "TPE1"); this.frameIDs.Add("TAL", "TALB"); this.frameIDs.Add("TT2", "TIT2"); using (ID3TagFileStream fs = new ID3TagFileStream(path, FileMode.Open)) { if (!fs.HaveID3v2()) { fs.Close(); isComplete = false; return; } version = fs.ReadVersion(); // Read ID3v2 version fs.ReadByte(); // Throw away flags byte // Read frames ReadFrames(fs, fs.ReadSize()); fs.Close(); string tempPath = System.IO.Path.GetFileNameWithoutExtension(path); if (title == "" || title == null) { title = tempPath; } if (artist == "" || artist == null) { artist = "Unknown"; } if (album == "" || album == null) { album = "Unknown"; } } }