Example #1
0
 public TagLib.Tag AddTag(TagTypes type, TagLib.Tag copy)
 {
     TagLib.Tag target = null;
     if (type == (TagTypes.None | TagTypes.Id3v1))
     {
         target = new TagLib.Id3v1.Tag();
     }
     else if (type == (TagTypes.None | TagTypes.Id3v2))
     {
         TagLib.Id3v2.Tag tag2;
         target = new TagLib.Id3v2.Tag {
             Version = 4,
             Flags = (byte) (tag2.Flags | HeaderFlags.FooterPresent)
         };
     }
     else if (type == (TagTypes.None | TagTypes.Ape))
     {
         target = new TagLib.Ape.Tag();
     }
     if (target != null)
     {
         if (copy != null)
         {
             copy.CopyTo(target, true);
         }
         if (type == (TagTypes.None | TagTypes.Id3v1))
         {
             base.AddTag(target);
             return target;
         }
         base.InsertTag(0, target);
     }
     return target;
 }
Example #2
0
		public TagLibReaderWriterBase(
			string witnessFileName,
			TagTypes tagTypes)
		{
			_witnessFilename = Guard.ForNullOrWhiteSpace(witnessFileName, nameof(witnessFileName));
			_tagTypes = tagTypes;
		}
        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <param name="caller"></param>
        public override void Parse(Stream input, TagTypes caller)
        {
            BinaryReader br = new BinaryReader(input);

            this._fillStyleCount = br.ReadByte();

            if (this._fillStyleCount.Equals(0xFF))
            {
                this._fillStyleCountExtended = br.ReadUInt16();

                this._fillStyles = new MorphFillStyle[this._fillStyleCountExtended];

                for (UInt16 i = 0; i < this._fillStyleCountExtended; i++)
                {
                    MorphFillStyle temp = new MorphFillStyle(this._SwfVersion);
                    temp.Parse(input);
                    this._fillStyles[i] = temp;
                }
            }
            else
            {
                this._fillStyles = new MorphFillStyle[this._fillStyleCount];

                for (byte i = 0; i < this._fillStyleCount; i++)
                {
                    MorphFillStyle temp = new MorphFillStyle(this._SwfVersion);
                    temp.Parse(input);
                    this._fillStyles[i] = temp;
                }
            }
        }
Example #4
0
 /// <summary>
 /// The way how object like lines and shapes get filled.
 /// </summary>
 /// <param name="InitialVersion">The version of the Swf file using this object.</param>
 public FillStyle(byte InitialVersion)
     : base(InitialVersion)
 {
     this._color = new Rgb(this._SwfVersion);
     this._gradientMatrix = new Matrix(this._SwfVersion);
     this._gradient = new Gradient(this._SwfVersion);
     this._bitmapMatrix = new Matrix(this._SwfVersion);
     this._caller = TagTypes.DefineShape;
 }
Example #5
0
		// Get the Apple Tag.
		public override TagLib.Tag FindTag(TagTypes type, bool create)
		{
			if (type == TagTypes.Apple)
			{
				if (tag == null && create)
					tag = new Mpeg4AppleTag(this);

				return tag;
			}

			return null;
		}
Example #6
0
 public override TagLib.Tag GetTag(TagTypes type, bool create)
 {
     if (type != TagTypes.Apple)
     {
         return null;
     }
     if ((this.apple_tag == null) && create)
     {
         this.apple_tag = new AppleTag(this.udta_box);
         TagLib.Tag[] tags = new TagLib.Tag[] { this.apple_tag };
         this.tag.SetTags(tags);
     }
     return this.apple_tag;
 }
Example #7
0
		private Tag FindMpcTag(TagTypes type, bool create)
		{
			switch (type)
			{
				case TagTypes.Id3v2:
					{
						if (create && id3v2Tag == null)
						{
							id3v2Tag = new Id3v2Tag();

							if (tag != null)
								TagLib.Tag.Duplicate(tag, id3v2Tag, true);

							tag.SetTags(apeTag, id3v2Tag, id3v1Tag);
						}
						return id3v2Tag;
					}

				case TagTypes.Id3v1:
					{
						if (create && id3v1Tag == null)
						{
							id3v1Tag = new Id3v1Tag();

							if (tag != null)
								TagLib.Tag.Duplicate(tag, id3v1Tag, true);

							tag.SetTags(apeTag, id3v2Tag, id3v1Tag);
						}
						return id3v1Tag;
					}

				case TagTypes.Ape:
					{
						if (create && apeTag == null)
						{
							apeTag = new ApeTag();

							if (tag != null)
								TagLib.Tag.Duplicate(tag, apeTag, true);

							tag.SetTags(apeTag, id3v2Tag, id3v1Tag);
						}
						return apeTag;
					}

				default:
					return null;
			}
		}
Example #8
0
 public override TagLib.Tag GetTag(TagTypes type, bool create)
 {
     TagLib.Tag tag = null;
     if (type != (TagTypes.None | TagTypes.Id3v2))
     {
         return tag;
     }
     if ((this.tag == null) && create)
     {
         this.tag = new TagLib.Id3v2.Tag();
         this.tag.Version = 2;
     }
     return this.tag;
 }
Example #9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <param name="caller"></param>
        public void Parse( Stream input, TagTypes caller )
        {
            BinaryReader br = new BinaryReader(input);
            this._ratio = br.ReadByte();

            if (caller.Equals(TagTypes.DefineShape3) || caller.Equals(TagTypes.DefineShape4))
            {
                this._color = new Rgba(this._SwfVersion);
                this._color.Parse(input);
            }
            else
            {
                this._color = new Rgb(this._SwfVersion);
                this._color.Parse(input);
            }
        }
Example #10
0
        public override TagLib.Tag GetTag(TagTypes type, bool create)
        {
            TagLib.Tag tag = null;
            switch (type)
            {
                case (TagTypes.None | TagTypes.Id3v2):
                    if ((this.id32_tag == null) && create)
                    {
                        this.id32_tag = new TagLib.Id3v2.Tag();
                        this.id32_tag.Version = 4;
                        this.id32_tag.Flags = (HeaderFlags) ((byte) (this.id32_tag.Flags | HeaderFlags.FooterPresent));
                        this.tag.CopyTo(this.id32_tag, true);
                    }
                    tag = this.id32_tag;
                    break;

                case TagTypes.RiffInfo:
                    if ((this.info_tag == null) && create)
                    {
                        this.info_tag = new InfoTag();
                        this.tag.CopyTo(this.info_tag, true);
                    }
                    tag = this.info_tag;
                    break;

                case TagTypes.MovieId:
                    if ((this.mid_tag == null) && create)
                    {
                        this.mid_tag = new MovieIdTag();
                        this.tag.CopyTo(this.mid_tag, true);
                    }
                    tag = this.mid_tag;
                    break;

                case TagTypes.DivX:
                    if ((this.divx_tag == null) && create)
                    {
                        this.divx_tag = new DivXTag();
                        this.tag.CopyTo(this.divx_tag, true);
                    }
                    tag = this.divx_tag;
                    break;
            }
            TagLib.Tag[] tags = new TagLib.Tag[] { this.id32_tag, this.info_tag, this.mid_tag, this.divx_tag };
            this.tag.SetTags(tags);
            return tag;
        }
Example #11
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <param name="caller"></param>
        public virtual void Parse( Stream input, TagTypes caller )
        {
            BitStream bits = new BitStream( input );
            GradRecord temp = new GradRecord(this._SwfVersion);

            this._spreadMode = ( SpreadMode )bits.GetBits( 2 );
            this._interpolationMode = ( InterPolation )bits.GetBits( 2 );
            this._numGradients = ( byte )bits.GetBits( 4 );

            bits.Reset();

            for ( int i = 0; i < this._numGradients; i++ )
            {
                temp = new GradRecord( this._SwfVersion );
                temp.Parse( input, caller );
                this._gradientRecords.Add( temp );
            }
        }
Example #12
0
        public override TagLib.Tag GetTag(TagTypes type, bool create)
        {
            TagLib.Tag tag = (this.Tag as TagLib.NonContainer.Tag).GetTag(type);
            if ((tag != null) || !create)
            {
                return tag;
            }
            switch (type)
            {
                case (TagTypes.None | TagTypes.Id3v1):
                    return base.EndTag.AddTag(type, this.Tag);

                case (TagTypes.None | TagTypes.Id3v2):
                    return base.StartTag.AddTag(type, this.Tag);

                case (TagTypes.None | TagTypes.Ape):
                    return base.EndTag.AddTag(type, this.Tag);
            }
            return null;
        }
Example #13
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <param name="caller"></param>
        public virtual void Parse(Stream input, TagTypes caller)
        {
            BinaryReader br = new BinaryReader(input);

            this._width = br.ReadUInt16();

            if (caller.Equals(TagTypes.DefineShape) || caller.Equals(TagTypes.DefineShape2))
            {
                this._color = new Rgb(this._SwfVersion);

                try
                {
                    this._color.Parse(input);
                }
                catch(SwfFormatException e)
                {
                    throw e;
                }

            }
            else if (caller.Equals(TagTypes.DefineShape3))
            {
                this._color = new Rgba(this._SwfVersion);

                try
                {
                    this._color.Parse(input);
                }
                catch (SwfFormatException e)
                {
                    throw e;
                }

            }
            else
            {
                SwfFormatException e = new SwfFormatException("LineStyle was called by illegal TagType (" + caller.ToString() +").");
               Log.Error(this, e.Message);
            }
        }
 public TagLib.Tag AddTag(TagTypes type, TagLib.Tag copy)
 {
     TagLib.Tag target = null;
     if (type == (TagTypes.None | TagTypes.Id3v2))
     {
         target = new TagLib.Id3v2.Tag();
     }
     else if (type == (TagTypes.None | TagTypes.Ape))
     {
         target = new TagLib.Ape.Tag();
         (target as TagLib.Ape.Tag).HeaderPresent = true;
     }
     if (target != null)
     {
         if (copy != null)
         {
             copy.CopyTo(target, true);
         }
         base.AddTag(target);
     }
     return target;
 }
Example #15
0
 public override TagLib.Tag GetTag(TagTypes type, bool create)
 {
     if (type == TagTypes.Xiph)
     {
         IEnumerator<XiphComment> enumerator = this.tag.Comments.GetEnumerator();
         try
         {
             while (enumerator.MoveNext())
             {
                 return enumerator.Current;
             }
         }
         finally
         {
             if (enumerator == null)
             {
             }
             enumerator.Dispose();
         }
     }
     return null;
 }
        public override void Validate(object value)
        {
            if (value is IEnumerable<TagTypes>)
            {
                return;
            }

            var val = value as string;

            if (val != null)
            {
                var parts = val.Split(',');
                var result = new TagTypes[parts.Length];
                for (var i = 0; i < parts.Length; i++)
                {
                    var part = parts[i];
                    result[i] = (TagTypes)Enum.Parse(typeof(TagTypes), part, true);
                }
            }

            throw new ArgumentException("Invalid input for IList<TagTypes>");
        }
Example #17
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="input"></param>
        /// <param name="caller"></param>
        public override void Parse(Stream input, TagTypes caller)
        {
            BinaryReader br = new BinaryReader(input);

            this._width = br.ReadUInt16();

            BitStream bits = new BitStream(input);

            this._startCapStyle = (CapStyle)(Convert.ToByte(bits.GetBits(2)));
            this._joinstyle = (JoinStyle)(Convert.ToByte(bits.GetBits(2)));

            this._hasFillFlag = (0 != bits.GetBits(1) ? true : false);
            this._noHScale = (0 != bits.GetBits(1) ? true : false);
            this._noVScale = (0 != bits.GetBits(1) ? true : false);
            this._pixelHinting = (0 != bits.GetBits(1) ? true : false);

            bits.GetBits(5); // reserved must be null

            this._noClose = (0 != bits.GetBits(1) ? true : false);

            this._endCapStyle = (CapStyle)bits.GetBits(2);

            if (this._joinstyle.Equals(JoinStyle.Miter))
            {
                bits.Reset();
                this._miterLimtiFactor = br.ReadUInt16();
            }
            if (!this._hasFillFlag)
            {
                bits.Reset();
                this._color.Parse(input);
            }
            if (this._hasFillFlag)
            {
                bits.Reset();
                this._fillStyle.Parse(input, caller);
            }
        }
Example #18
0
        public override TagLib.Tag GetTag(TagTypes type, bool create)
        {
            TagTypes types;
            switch (type)
            {
                case TagTypes.Xiph:
                    return this.metadata.GetComment(create, this.tag);

                case TagTypes.FlacMetadata:
                    return this.metadata;

                default:
                {
                    TagLib.Tag tag = (base.Tag as TagLib.NonContainer.Tag).GetTag(type);
                    if ((tag != null) || !create)
                    {
                        return tag;
                    }
                    types = type;
                    switch (types)
                    {
                        case (TagTypes.None | TagTypes.Id3v1):
                            return base.EndTag.AddTag(type, this.Tag);

                        case (TagTypes.None | TagTypes.Id3v2):
                            return base.StartTag.AddTag(type, this.Tag);
                    }
                    break;
                }
            }
            if (types == (TagTypes.None | TagTypes.Ape))
            {
                return base.EndTag.AddTag(type, this.Tag);
            }
            return null;
        }
Example #19
0
		/// <summary>
		///    Gets a tag of a specified type from the current instance,
		///    optionally creating a new tag if possible.
		/// </summary>
		/// <param name="type">
		///    A <see cref="TagLib.TagTypes" /> value indicating the
		///    type of tag to read.
		/// </param>
		/// <param name="create">
		///    A <see cref="bool" /> value specifying whether or not to
		///    try and create the tag if one is not found.
		/// </param>
		/// <returns>
		///    A <see cref="Tag" /> object containing the tag that was
		///    found in or added to the current instance. If no
		///    matching tag was found and none was created, <see
		///    langref="null" /> is returned.
		/// </returns>
		/// <remarks>
		///    If a <see cref="TagLib.Id3v2.Tag" /> is added to the
		///    current instance, it will be placed at the start of the
		///    file. On the other hand, <see cref="TagLib.Id3v1.Tag" />
		///    <see cref="TagLib.Ape.Tag" /> will be added to the end of
		///    the file. All other tag types will be ignored.
		/// </remarks>
		public override TagLib.Tag GetTag (TagTypes type, bool create)
		{
			Tag t = (Tag as TagLib.NonContainer.Tag).GetTag (type);
			
			if (t != null || !create)
				return t;
			
			switch (type)
			{
			case TagTypes.Id3v1:
				return EndTag.AddTag (type, Tag);
			
			case TagTypes.Id3v2:
				return EndTag.AddTag (type, Tag);
			
			case TagTypes.Ape:
				return EndTag.AddTag (type, Tag);
			
			default:
				return null;
			}
		}
Example #20
0
 public override void RemoveTags(TagTypes types)
 {
     throw new System.NotImplementedException ();
 }
Example #21
0
 public override Tag GetTag(TagTypes type, bool create)
 {
     throw new System.NotImplementedException ();
 }
Example #22
0
        /// <summary>
        ///    Removes a set of tag types from the current instance.
        /// </summary>
        /// <param name="types">
        ///    A bitwise combined <see cref="TagLib.TagTypes" /> value
        ///    containing tag types to be removed from the file.
        /// </param>
        /// <remarks>
        ///    In order to remove all tags from a file, pass <see
        ///    cref="TagTypes.AllTags" /> as <paramref name="types" />.
        /// </remarks>
        public override void RemoveTags(TagTypes types)
        {
            if ((types & TagLib.TagTypes.Id3v2) != TagLib.TagTypes.None)
                id32_tag = null;
            if ((types & TagLib.TagTypes.RiffInfo) != TagLib.TagTypes.None)
                info_tag = null;
            if ((types & TagLib.TagTypes.MovieId) != TagLib.TagTypes.None)
                mid_tag  = null;
            if ((types & TagLib.TagTypes.DivX) != TagLib.TagTypes.None)
                divx_tag = null;

            tag.SetTags (id32_tag, info_tag, mid_tag, divx_tag);
        }
Example #23
0
        /// <summary>
        ///    Gets a tag of a specified type from the current instance,
        ///    optionally creating a new tag if possible.
        /// </summary>
        /// <param name="type">
        ///    A <see cref="TagLib.TagTypes" /> value indicating the
        ///    type of tag to read.
        /// </param>
        /// <param name="create">
        ///    A <see cref="bool" /> value specifying whether or not to
        ///    try and create the tag if one is not found.
        /// </param>
        /// <returns>
        ///    A <see cref="Tag" /> object containing the tag that was
        ///    found in or added to the current instance. If no
        ///    matching tag was found and none was created, <see
        ///    langword="null" /> is returned.
        /// </returns>
        public override TagLib.Tag GetTag(TagTypes type, bool create)
        {
            TagLib.Tag tag = null;

            switch (type)
            {
            case TagTypes.Id3v2:
                if (id32_tag == null && create) {
                    id32_tag = new Id3v2.Tag ();
                    id32_tag.Version = 4;
                    id32_tag.Flags |= Id3v2.HeaderFlags
                        .FooterPresent;
                    this.tag.CopyTo (id32_tag, true);
                }

                tag = id32_tag;
                break;

            case TagTypes.RiffInfo:
                if (info_tag == null && create) {
                    info_tag = new InfoTag ();
                    this.tag.CopyTo (info_tag, true);
                }

                tag = info_tag;
                break;

            case TagTypes.MovieId:
                if (mid_tag == null && create) {
                    mid_tag = new MovieIdTag ();
                    this.tag.CopyTo (mid_tag, true);
                }

                tag = mid_tag;
                break;

            case TagTypes.DivX:
                if (divx_tag == null && create) {
                    divx_tag = new DivXTag ();
                    this.tag.CopyTo (divx_tag, true);
                }

                tag = divx_tag;
                break;
            }

            this.tag.SetTags (id32_tag, info_tag, mid_tag, divx_tag);
            return tag;
        }
 /// <summary>
 ///    Removes a set of tag types from the current instance.
 /// </summary>
 /// <param name="types">
 ///    A bitwise combined <see cref="TagLib.TagTypes" /> value
 ///    containing tag types to be removed from the file.
 /// </param>
 /// <remarks>
 ///    In order to remove all tags from a file, pass <see
 ///    cref="TagTypes.AllTags" /> as <paramref name="types" />.
 /// </remarks>
 public override void RemoveTags(TagTypes types)
 {
     if (types == TagLib.TagTypes.Id3v2 ||
         types == TagLib.TagTypes.AllTags)
     {
         tag = null;
     }
 }
        /// <summary>
        ///    Gets a tag of a specified type from the current instance,
        ///    optionally creating a new tag if possible.
        /// </summary>
        /// <param name="type">
        ///    A <see cref="TagLib.TagTypes" /> value indicating the
        ///    type of tag to read.
        /// </param>
        /// <param name="create">
        ///    A <see cref="bool" /> value specifying whether or not to
        ///    try and create the tag if one is not found.
        /// </param>
        /// <returns>
        ///    A <see cref="Tag" /> object containing the tag that was
        ///    found in or added to the current instance. If no
        ///    matching tag was found and none was created, <see
        ///    langword="null" /> is returned.
        /// </returns>
        public override TagLib.Tag GetTag(TagTypes type, bool create)
        {
            TagLib.Tag id32_tag = null;

            switch (type)
            {
                case TagTypes.Id3v2:
                    if (tag == null && create)
                    {
                        tag = new Id3v2.Tag();
                        tag.Version = 2;
                    }

                    id32_tag = tag;
                    break;
            }

            return id32_tag;
        }
Example #26
0
		/// <summary>
		///    Gets a tag of a specified type from the current instance.
		/// </summary>
		/// <param name="type">
		///    A <see cref="TagLib.TagTypes" /> value indicating the
		///    type of tag to read.
		/// </param>
		/// <returns>
		///    A <see cref="Tag" /> object containing the tag that was
		///    found in the current instance. If no matching tag
		///    was found, <see langword="null" /> is returned.
		/// </returns>
		/// <remarks>
		///    <para>This class merely accesses the tag if it exists.
		///    <see cref="GetTag(TagTypes,bool)" /> provides the option
		///    of adding the tag to the current instance if it does not
		///    exist.</para>
		///    <para>It is safe to assume that if <see langword="null"
		///    /> is not returned, the returned tag can be cast to the
		///    appropriate type.</para>
		/// </remarks>
		/// <example>
		///    <para>The following example reads the mood of a file from
		///    several tag types.</para>
		///    <code lang="C#">static string [] GetMoods (TagLib.File file)
		///{
		///   TagLib.Id3v2.Tag id3 = file.GetTag (TagLib.TagTypes.Id3v2);
		///   if (id3 != null) {
		///      TextIdentificationFrame f = TextIdentificationFrame.Get (this, "TMOO");
		///      if (f != null)
		///         return f.FieldList.ToArray ();
		///   }
		///   
		///   TagLib.Asf.Tag asf = file.GetTag (TagLib.TagTypes.Asf);
		///   if (asf != null) {
		///      string [] value = asf.GetDescriptorStrings ("WM/Mood", "Mood");
		///      if (value.Length &gt; 0)
		///         return value;
		///   }
		///   
		///   TagLib.Ape.Tag ape = file.GetTag (TagLib.TagTypes.Ape);
		///   if (ape != null) {
		///      Item item = ape.GetItem ("MOOD");
		///      if (item != null)
		///         return item.ToStringArray ();
		///   }
		///      
		///   // Whatever tag types you want...
		///   
		///   return new string [] {};
		///}</code>
		/// </example>
		public Tag GetTag (TagTypes type)
		{
			return GetTag (type, false);
		}
Example #27
0
		/// <summary>
		///    Gets a tag of a specified type from the current instance,
		///    optionally creating a new tag if possible.
		/// </summary>
		/// <param name="type">
		///    A <see cref="TagLib.TagTypes" /> value indicating the
		///    type of tag to read.
		/// </param>
		/// <param name="create">
		///    A <see cref="bool" /> value specifying whether or not to
		///    try and create the tag if one is not found.
		/// </param>
		/// <returns>
		///    A <see cref="Tag" /> object containing the tag that was
		///    found in or added to the current instance. If no
		///    matching tag was found and none was created, <see
		///    langword="null" /> is returned.
		/// </returns>
		/// <remarks>
		///    <para>Passing <see langword="true" /> to <paramref
		///    name="create" /> does not guarantee the tag will be
		///    created. For example, trying to create an ID3v2 tag on an
		///    OGG Vorbis file will always fail.</para>
		///    <para>It is safe to assume that if <see langword="null"
		///    /> is not returned, the returned tag can be cast to the
		///    appropriate type.</para>
		/// </remarks>
		/// <example>
		///    <para>The following example sets the mood of a file to
		///    several tag types.</para>
		///    <code lang="C#">string [] SetMoods (TagLib.File file, params string[] moods)
		///{
		///   TagLib.Id3v2.Tag id3 = file.GetTag (TagLib.TagTypes.Id3v2, true);
		///   if (id3 != null)
		///      id3.SetTextFrame ("TMOO", moods);
		///   
		///   TagLib.Asf.Tag asf = file.GetTag (TagLib.TagTypes.Asf, true);
		///   if (asf != null)
		///      asf.SetDescriptorStrings (moods, "WM/Mood", "Mood");
		///   
		///   TagLib.Ape.Tag ape = file.GetTag (TagLib.TagTypes.Ape);
		///   if (ape != null)
		///      ape.SetValue ("MOOD", moods);
		///      
		///   // Whatever tag types you want...
		///}</code>
		/// </example>
		public abstract Tag GetTag (TagTypes type, bool create);
Example #28
0
		/// <summary>
		///    Removes a set of tag types from the current instance.
		/// </summary>
		/// <param name="types">
		///    A bitwise combined <see cref="TagLib.TagTypes" /> value
		///    containing tag types to be removed from the file.
		/// </param>
		/// <remarks>
		///    In order to remove all tags from a file, pass <see
		///    cref="TagTypes.AllTags" /> as <paramref name="types" />.
		/// </remarks>
		public abstract void RemoveTags (TagTypes types);
Example #29
0
        /// <summary>
        ///    Removes a set of tag types from the current instance.
        /// </summary>
        /// <param name="types">
        ///    A bitwise combined <see cref="TagLib.TagTypes" /> value
        ///    containing tag types to be removed from the file.
        /// </param>
        /// <remarks>
        ///    In order to remove all tags from a file, pass <see
        ///    cref="TagTypes.AllTags" /> as <paramref name="types" />.
        /// </remarks>
        public override void RemoveTags(TagTypes types)
        {
            if ((types & TagTypes.Xiph) != 0)
                metadata.RemoveComment ();

            if ((types & TagTypes.FlacMetadata) != 0)
                metadata.Clear ();

            base.RemoveTags (types);
        }
Example #30
0
        /// <summary>
        ///    Gets a tag of a specified type from the current instance,
        ///    optionally creating a new tag if possible.
        /// </summary>
        /// <param name="type">
        ///    A <see cref="TagLib.TagTypes" /> value indicating the
        ///    type of tag to read.
        /// </param>
        /// <param name="create">
        ///    A <see cref="bool" /> value specifying whether or not to
        ///    try and create the tag if one is not found.
        /// </param>
        /// <returns>
        ///    A <see cref="Tag" /> object containing the tag that was
        ///    found in or added to the current instance. If no
        ///    matching tag was found and none was created, <see
        ///    langword="null" /> is returned.
        /// </returns>
        public override TagLib.Tag GetTag(TagTypes type, bool create)
        {
            switch (type)
            {
            case TagTypes.Xiph:
                return metadata.GetComment (create, tag);

            case TagTypes.FlacMetadata:
                return metadata;
            }

            Tag t = (base.Tag as TagLib.NonContainer.Tag).GetTag (type);

            if (t != null || !create)
                return t;

            switch (type)
            {
            case TagTypes.Id3v1:
                return EndTag.AddTag (type, Tag);

            case TagTypes.Id3v2:
                return StartTag.AddTag (type, Tag);

            case TagTypes.Ape:
                return EndTag.AddTag (type, Tag);

            default:
                return null;
            }
        }