Esempio n. 1
0
 public TagLib.Tag AddTag(TagTypes type, TagLib.Tag copy)
 {
     TagLib.Tag tag = null;
     if (type == TagTypes.Id3v1)
     {
         tag = new TagLib.Id3v1.Tag();
     }
     else if (type == TagTypes.Id3v2)
     {
         Id3v2.Tag tag32 = new Id3v2.Tag();
         tag32.Version = 4;
         tag32.Flags  |= Id3v2.HeaderFlags.FooterPresent;
         tag           = tag32;
     }
     else if (type == TagTypes.Ape)
     {
         tag = new TagLib.Ape.Tag();
     }
     if (tag != null)
     {
         if (copy != null)
         {
             copy.CopyTo(tag, true);
         }
         if (type == TagTypes.Id3v1)
         {
             AddTag(tag);
         }
         else
         {
             InsertTag(0, tag);
         }
     }
     return(tag);
 }
Esempio n. 2
0
        /// <summary>
        ///    Adds a tag of a specified type to the current instance,
        ///    optionally copying values from an existing type.
        /// </summary>
        /// <param name="type">
        ///    A <see cref="TagTypes" /> value specifying the type of
        ///    tag to add to the current instance. At the time of this
        ///    writing, this is limited to <see cref="TagTypes.Ape" />
        ///    and <see cref="TagTypes.Id3v2" />.
        /// </param>
        /// <param name="copy">
        ///    A <see cref="TagLib.Tag" /> to copy values from using
        ///    <see cref="TagLib.Tag.CopyTo" />, or <see
        ///    langword="null" /> if no tag is to be copied.
        /// </param>
        /// <returns>
        ///    The <see cref="TagLib.Tag" /> object added to the current
        ///    instance, or <see langref="null" /> if it couldn't be
        ///    created.
        /// </returns>
        /// <remarks>
        ///    ID3v2 tags are added at the end of the current instance,
        ///    while other tags are added to the beginning.
        /// </remarks>
        public TagLib.Tag AddTag(TagTypes type, TagLib.Tag copy)
        {
            TagLib.Tag tag = null;

            if (type == TagTypes.Id3v2)
            {
                tag = new TagLib.Id3v2.Tag();
            }
            else if (type == TagTypes.Ape)
            {
                tag = new TagLib.Ape.Tag();
                (tag as Ape.Tag).HeaderPresent = true;
            }

            if (tag != null)
            {
                if (copy != null)
                {
                    copy.CopyTo(tag, true);
                }

                AddTag(tag);
            }

            return(tag);
        }
Esempio n. 3
0
        /// <summary>
        /// Save <see cref="TagLib.Tag"/> into specified separated file.
        /// </summary>
        /// <remarks>
        /// It is saving only tags. It won't save pictures in it.
        /// </remarks>
        /// <param name="tag"></param>
        /// <param name="fileName"></param>
        /// <param name="mimeType"></param>
        /// <param name="style"></param>
        public static void PutIntoFile(this TagLib.Tag tag, string fileName, string mimeType = "audio/mpeg", TagLib.ReadStyle style = TagLib.ReadStyle.None)
        {
            using TagLib.File tlb = TagLib.File.Create(fileName, mimeType, style);

            tag.CopyTo(tlb.Tag, true);
            tlb.Save();
        }