Pregunta

Necesito etiquetar archivos MP3 con una carátula en C # ...

¿Hay alguna manera fácil de hacer esto? Encontré UltraID3Lib como un examen y es ideal para el etiquetado ID3 normal, pero no puedo manejar la portada. Si alguien conoce una manera fácil de hacerlo, sería genial :)

¿Fue útil?

Solución

Hago algo como esto :

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;
}

Estoy en el trabajo y olvidé activar Foldershare, así que no puedo mostrar mi versión recortada donde paso un objeto de imagen, pero esto tiene todo lo que necesita para hacer el trabajo con un poco de pirateo . Buena suerte.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top