Logo Search packages:      
Sourcecode: taglib-sharp version File versions

TagLib::Id3v2::AttachedPictureFrame::AttachedPictureFrame ( IPicture  picture  )  [inline]

Constructs and initializes a new instance of AttachedPictureFrame by populating it with the contents of another IPicture object.

picture A IPicture object containing values to use in the new instance.
ArgumentNullException picture is .

When a frame is created, it is not automatically added to the tag. Consider using Get(Tag,string,PictureType,bool) for more integrated frame creation.

Additionally, TagLib.Tag.Pictures provides a generic way or getting and setting pictures which is preferable to format specific code.

Add a picture to a file.

                using TagLib;
                using TagLib.Id3v2;

                public static class AddId3v2Picture
                  public static void Main (string [] args)
                        if (args.Length != 2)
                              throw new ApplicationException (
                                    "USAGE: AddId3v2Picture.exe AUDIO_FILE PICTURE_FILE");

Create the file. Can throw file to TagLib# exceptions.
                        File file = File.Create (args [0]);

Get or create the ID3v2 tag.
                        TagLib.Id3v2.Tag tag = file.GetTag (TagTypes.Id3v2, true) as TagLib.Id3v2.Tag;
                        if (tag == null)
                              throw new ApplicationException ("File does not support ID3v2 tags.");

Create a picture. Can throw file related exceptions.
                        TagLib.Picture picture = TagLib.Picture.CreateFromPath (path);

Add a new picture frame to the tag.
                        tag.AddFrame (new AttachedPictureFrame (picture));

Save the file.
                        file.Save ();

Definition at line 176 of file AttachedPictureFrame.cs.

                  : base(FrameType.APIC, 4)
                  if (picture == null)
                        throw new ArgumentNullException ("picture");
                  mime_type   = picture.MimeType;
                  type        = picture.Type;
                  description = picture.Description;
                  data        = picture.Data;

Generated by  Doxygen 1.6.0   Back to index