使用C#查看和编辑ID3标签(艺术家,专辑等)的快捷方式是什么?
Thirding TagLib Sharp.
TagLib.File f = TagLib.File.Create(path); f.Tag.Album = "New Album Title"; f.Save();
TagLib Sharp很受欢迎.
作为旁注,如果你想快速而又肮脏地偷看自己做的话......这里有一个C#片段,我发现它可以读取mp3的标签信息.
class MusicID3Tag { public byte[] TAGID = new byte[3]; // 3 public byte[] Title = new byte[30]; // 30 public byte[] Artist = new byte[30]; // 30 public byte[] Album = new byte[30]; // 30 public byte[] Year = new byte[4]; // 4 public byte[] Comment = new byte[30]; // 30 public byte[] Genre = new byte[1]; // 1 } string filePath = @"C:\Documents and Settings\All Users\Documents\My Music\Sample Music\041105.mp3"; using (FileStream fs = File.OpenRead(filePath)) { if (fs.Length >= 128) { MusicID3Tag tag = new MusicID3Tag(); fs.Seek(-128, SeekOrigin.End); fs.Read(tag.TAGID, 0, tag.TAGID.Length); fs.Read(tag.Title, 0, tag.Title.Length); fs.Read(tag.Artist, 0, tag.Artist.Length); fs.Read(tag.Album, 0, tag.Album.Length); fs.Read(tag.Year, 0, tag.Year.Length); fs.Read(tag.Comment, 0, tag.Comment.Length); fs.Read(tag.Genre, 0, tag.Genre.Length); string theTAGID = Encoding.Default.GetString(tag.TAGID); if (theTAGID.Equals("TAG")) { string Title = Encoding.Default.GetString(tag.Title); string Artist = Encoding.Default.GetString(tag.Artist); string Album = Encoding.Default.GetString(tag.Album); string Year = Encoding.Default.GetString(tag.Year); string Comment = Encoding.Default.GetString(tag.Comment); string Genre = Encoding.Default.GetString(tag.Genre); Console.WriteLine(Title); Console.WriteLine(Artist); Console.WriteLine(Album); Console.WriteLine(Year); Console.WriteLine(Comment); Console.WriteLine(Genre); Console.WriteLine(); } } }
UltraID3Lib ......
//using HundredMilesSoftware.UltraID3Lib; UltraID3 u = new UltraID3(); u.Read(@"C:\mp3\song.mp3"); //view Console.WriteLine(u.Artist); //edit u.Artist = "New Artist"; u.Write();
TagLib Sharp支持读取ID3标签.