题
我需要在C#...点击一个封面标记的MP3文件 点击 有没有简单的方法来做到这一点?我发现UltraID3Lib作为exampel,它是伟大的常规ID3标签,但我不能处理的封面。如果有人知道一个简单的方法来做到这一点,将是巨大的:)
解决方案
余像做此:
private static void FixAlbumArt(FileInfo MyFile)
{
//Find the jpeg file in the directory of the Mp3 File
//We will embed this image into the ID3v2 tag
FileInfo[] fiAlbumArt = MyFile.Directory.GetFiles("*.jpg");
if (fiAlbumArt.Length < 1)
{
Console.WriteLine("No Album Art Found in {0}", MyFile.Directory.Name);
return;
}
string AlbumArtFile = fiAlbumArt[0].FullName;
//Create Mp3 Object
UltraID3 myMp3 = new UltraID3();
myMp3.Read(MyFile.FullName);
ID3FrameCollection myArtworkCollection =
myMp3.ID3v23Tag.Frames.GetFrames(MultipleInstanceFrameTypes.Picture);
if (myArtworkCollection.Count > 0)
{//Get Rid of the Bad Embedded Artwork
#region Remove All Old Artwork
for (int i = 0; i < myArtworkCollection.Count; i++)
{
ID3PictureFrame ra = (ID3PictureFrame)myArtworkCollection[0];
try
{
myMp3.ID3v23Tag.Frames.Remove(FrameTypes.Picture);
}
catch { }
}
myArtworkCollection.Clear();
//Save out our changes so that we are working with the
//most up to date file and tags
myMp3.ID3v23Tag.WriteFlag = true;
myMp3.Write();
myMp3.Read(MyFile.FullName);
#endregion Remove All Old Artwork
}
//Create a PictureFrame object, pointing it at the image on my PC
ID3PictureFrame AlbumArt =
new ID3PictureFrame(
(System.Drawing.Bitmap)System.Drawing.Bitmap.FromFile(AlbumArtFile),
PictureTypes.CoverFront, "Attached picture", TextEncodingTypes.ISO88591);
myMp3.ID3v23Tag.Frames.Add(AlbumArt);
myMp3.ID3v23Tag.WriteFlag = true;
myMp3.Write();
myMp3 = null;
}
我在工作时忘了打开的FolderShare所以,我传递一个Image对象,我不能告诉你我的下调版本,但这个拥有一切你需要把工作带位的安全的做。好运。
不隶属于 StackOverflow