Exemple #1
0
        private void Read(ReadStyle propertiesStyle)
        {
            // Look for an ID3v1 tag

            long id3v1Location = FindId3v1();

            if (id3v1Location >= 0)
            {
                id3v1Tag = new Id3v1Tag(this, id3v1Location);
            }

            // Look for an APE tag

            long apeLocation = FindApe(id3v1Location != -1);

            if (apeLocation >= 0)
            {
                apeTag = new ApeTag(this, apeLocation);
            }

            tag.SetTags(apeTag, id3v1Tag);
            FindWavPackTag(TagTypes.Ape, true);

            // Look for MPC metadata

            if (propertiesStyle != ReadStyle.None)
            {
                Seek(0);
                properties = new WavPackProperties(ReadBlock((int)WavPackProperties.HeaderSize),
                                                   apeLocation + ApeFooter.Size - apeTag.Footer.CompleteTagSize);
            }
        }
Exemple #2
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);
            }
        }
        private Tag FindFlacTag(TagTypes type, bool create)
        {
            switch (type)
            {
            case TagTypes.Id3v1:
            {
                if (create && id3v1_tag == null)
                {
                    id3v1_tag = new Id3v1Tag();

                    if (tag != null)
                    {
                        TagLib.Tag.Duplicate(tag, id3v1_tag, true);
                    }

                    tag.SetTags(comment, id3v2_tag, id3v1_tag);
                }
                return(id3v1_tag);
            }

            case TagTypes.Id3v2:
            {
                if (create && id3v2_tag == null)
                {
                    id3v2_tag = new Id3v2Tag();

                    if (tag != null)
                    {
                        TagLib.Tag.Duplicate(tag, id3v2_tag, true);
                    }

                    tag.SetTags(comment, id3v2_tag, id3v1_tag);
                }
                return(id3v2_tag);
            }

            case TagTypes.Xiph:
            {
                if (create && comment == null)
                {
                    comment = new OggXiphComment();

                    if (tag != null)
                    {
                        TagLib.Tag.Duplicate(tag, comment, true);
                    }

                    tag.SetTags(comment, id3v2_tag, id3v1_tag);
                }
                return(comment);
            }

            default:
                return(null);
            }
        }
        private void Read(ReadStyle propertiesStyle)
        {
            long flacDataBegin;
            long flacDataEnd;

            // Look for an ID3v2 tag
            long id3v2Location = FindId3v2();

            if (id3v2Location >= 0)
            {
                id3v2_tag     = new Id3v2Tag(this, id3v2Location);
                flacDataBegin = id3v2Location + id3v2_tag.Header.CompleteTagSize;
            }
            else
            {
                flacDataBegin = 0;
            }

            // Look for an ID3v1 tag
            long id3v1_location = FindId3v1();

            if (id3v1_location >= 0)
            {
                id3v1_tag   = new Id3v1Tag(this, id3v1_location);
                flacDataEnd = id3v1_location;
            }
            else
            {
                flacDataEnd = Length;
            }

            // Look for FLAC metadata, including vorbis comments

            xiph_comment_data = Scan(flacDataBegin, flacDataEnd);

            if (!IsValid)
            {
                return;
            }

            if (XiphCommentData.Count > 0)
            {
                comment = new OggXiphComment(XiphCommentData);
            }

            tag.SetTags(comment, id3v2_tag, id3v1_tag);

            FindFlacTag(TagTypes.Xiph, true);

            if (propertiesStyle != ReadStyle.None)
            {
                properties = new FlacProperties(stream_info_data, stream_length, propertiesStyle);
            }
        }
Exemple #5
0
        public void Remove(TagTypes types)
        {
            if ((types & TagTypes.Id3v1) != 0)
            {
                id3v1Tag = null;
            }

            if ((types & TagTypes.Ape) != 0)
            {
                apeTag = null;
            }

            tag.SetTags(apeTag, id3v1Tag);
        }
		private Tag FindMpegTag(TagTypes type, bool create)
		{
			switch (type)
			{
				case TagTypes.Id3v1:
					{
						if (create && id3v1_tag == null)
						{
							id3v1_tag = new Id3v1Tag();
							TagLib.Tag.Duplicate(tag, id3v1_tag, true);
							tag.SetTags(id3v2_tag, ape_tag, id3v1_tag);
						}

						return id3v1_tag;
					}

				case TagTypes.Id3v2:
					{
						if (create && id3v2_tag == null)
						{
							id3v2_tag = new Id3v2Tag();
							TagLib.Tag.Duplicate(tag, id3v2_tag, true);
							tag.SetTags(id3v2_tag, ape_tag, id3v1_tag);
						}

						return id3v2_tag;
					}

				case TagTypes.Ape:
					{
						if (create && ape_tag == null)
						{
							ape_tag = new ApeTag();
							TagLib.Tag.Duplicate(tag, ape_tag, true);
							tag.SetTags(id3v2_tag, ape_tag, id3v1_tag);
						}

						return ape_tag;
					}

				default:
					return null;
			}
		}
Exemple #7
0
        private void Read(ReadStyle propertiesStyle)
        {
            // Look for an ID3v1 tag
            long id3v1Location = FindId3v1();

            if (id3v1Location >= 0)
            {
                id3v1Tag = new Id3v1Tag(this, id3v1Location);
            }


            // Look for an APE tag
            long apeLocation = FindApe(id3v1Location != 0);

            if (apeLocation >= 0)
            {
                apeTag = new ApeTag(this, apeLocation);
            }


            // Look for an ID3v2 tag
            long id3v2Location = FindId3v2();

            if (id3v2Location >= 0)
            {
                id3v2Tag = new Id3v2Tag(this, id3v2Location);
            }


            tag.SetTags(apeTag, id3v2Tag, id3v1Tag);
            FindMpcTag(TagTypes.Ape, true);


            // Look for MPC metadata
            Seek((id3v2Location >= 0) ? (id3v2Location + id3v2Tag.Header.CompleteTagSize) : 0);

            if (propertiesStyle != ReadStyle.None)
            {
                properties = new MpcProperties(ReadBlock((int)MpcProperties.HeaderSize),
                                               Length - Tell - apeTag.Footer.CompleteTagSize);
            }
        }
Exemple #8
0
        private void Read(ReadStyle propertiesStyle)
        {
            // Look for an ID3v2 tag
            long id3v2_location = FindId3v2();

            if (id3v2_location >= 0)
            {
                id3v2_tag = new Id3v2Tag(this, id3v2_location);
            }


            // Look for an ID3v1 tag
            long id3v1_location = FindId3v1();

            if (id3v1_location >= 0)
            {
                id3v1_tag = new Id3v1Tag(this, id3v1_location);
            }


            // Look for an APE tag
            long ape_location = FindApe(id3v1_location >= 0);

            if (ape_location >= 0)
            {
                ape_tag = new ApeTag(this, ape_location);
            }


            tag.SetTags(id3v2_tag, ape_tag, id3v1_tag);

            FindMpegTag(TagTypes.Id3v2, true);

            if (propertiesStyle != ReadStyle.None)
            {
                properties = new MpegProperties(this, propertiesStyle);
            }
        }
		public void Remove(TagTypes types)
		{
			if ((types & TagTypes.Id3v1) != 0)
				id3v1Tag = null;

			if ((types & TagTypes.Ape) != 0)
				apeTag = null;

			tag.SetTags(apeTag, id3v1Tag);
		}
		private void Read(ReadStyle propertiesStyle)
		{
			// Look for an ID3v1 tag

			long id3v1Location = FindId3v1();

			if (id3v1Location >= 0)
				id3v1Tag = new Id3v1Tag(this, id3v1Location);

			// Look for an APE tag

			long apeLocation = FindApe(id3v1Location != -1);

			if (apeLocation >= 0)
				apeTag = new ApeTag(this, apeLocation);

			tag.SetTags(apeTag, id3v1Tag);
			FindWavPackTag(TagTypes.Ape, true);

			// Look for MPC metadata

			if (propertiesStyle != ReadStyle.None)
			{
				Seek(0);
				properties = new WavPackProperties(ReadBlock((int)WavPackProperties.HeaderSize),
				   apeLocation + ApeFooter.Size - apeTag.Footer.CompleteTagSize);
			}
		}
Exemple #11
0
		private Tag FindFlacTag(TagTypes type, bool create)
		{
			switch (type)
			{
				case TagTypes.Id3v1:
					{
						if (create && id3v1_tag == null)
						{
							id3v1_tag = new Id3v1Tag();

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

							tag.SetTags(comment, id3v2_tag, id3v1_tag);
						}
						return id3v1_tag;
					}

				case TagTypes.Id3v2:
					{
						if (create && id3v2_tag == null)
						{
							id3v2_tag = new Id3v2Tag();

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

							tag.SetTags(comment, id3v2_tag, id3v1_tag);
						}
						return id3v2_tag;
					}

				case TagTypes.Xiph:
					{
						if (create && comment == null)
						{
							comment = new OggXiphComment();

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

							tag.SetTags(comment, id3v2_tag, id3v1_tag);
						}
						return comment;
					}

				default:
					return null;
			}
		}
Exemple #12
0
		private void Read(ReadStyle propertiesStyle)
		{
			long flacDataBegin;
			long flacDataEnd;

			// Look for an ID3v2 tag
			long id3v2Location = FindId3v2();

			if (id3v2Location >= 0)
			{
				id3v2_tag = new Id3v2Tag(this, id3v2Location);
				flacDataBegin = id3v2Location + id3v2_tag.Header.CompleteTagSize;
			}
			else
				flacDataBegin = 0;

			// Look for an ID3v1 tag
			long id3v1_location = FindId3v1();

			if (id3v1_location >= 0)
			{
				id3v1_tag = new Id3v1Tag(this, id3v1_location);
				flacDataEnd = id3v1_location;
			}
			else
				flacDataEnd = Length;

			// Look for FLAC metadata, including vorbis comments

			xiph_comment_data = Scan(flacDataBegin, flacDataEnd);

			if (!IsValid) return;

			if (XiphCommentData.Count > 0)
				comment = new OggXiphComment(XiphCommentData);

			tag.SetTags(comment, id3v2_tag, id3v1_tag);

			FindFlacTag(TagTypes.Xiph, true);

			if (propertiesStyle != ReadStyle.None)
				properties = new FlacProperties(stream_info_data, stream_length, propertiesStyle);
		}
Exemple #13
0
		public bool Strip (TagTypes types, bool freeMemory)
		{
			FileAccessMode original_mode = Mode;
         
			if(IsReadOnly)
			{
				TagLibDebugger.Debug("Mpeg.File.Strip() - Cannot strip tags from a read only file.");
				return false;
			}
         
			try
			{
				Mode = FileAccessMode.Write;
			}
			catch (TagLibException)
			{
				TagLibDebugger.Debug("Mpeg.File.Strip() - Cannot strip tags from a read only file.");
				return false;
			}

			if ((types & TagTypes.Id3v2) != 0)
			{
				long id3v2_location = FindId3v2 ();
				if (id3v2_location >= 0)
				{
					Seek(id3v2_location);
					Id3v2Header header = new Id3v2Header (ReadBlock ((int)Id3v2Header.Size));
               
					if (header.TagSize == 0)
						TagLibDebugger.Debug ("Mpc.File.Save() -- Id3v2 header is broken. Ignoring.");
					else
						RemoveBlock (id3v2_location, (int) header.CompleteTagSize);
				}
            
				if (freeMemory)
					id3v2_tag = null;
			}

			long id3v1_location = FindId3v1 ();
         
			if ((types & TagTypes.Id3v1) != 0)
			{
				if (id3v1_location >= 0)
				{
					Truncate(id3v1_location);
					id3v1_location = -1;
				}
            
				if (freeMemory)
					id3v1_tag = null;
			}

			if ((types & TagTypes.Ape) != 0)
			{
				long ape_location = FindApe (id3v1_location >= 0);
				if (ape_location != -1)
				{
					Seek(ape_location);
					int ape_size = (int) (new ApeFooter(ReadBlock((int) ApeFooter.Size))).CompleteTagSize;
					ape_location = ape_location + ApeFooter.Size - ape_size;
					RemoveBlock(ape_location, ape_size);
				}
            
				if (freeMemory)
					ape_tag = null;
			}
         
			tag.SetTags(id3v2_tag, ape_tag, id3v1_tag);
         
			Mode = original_mode;
			return true;
		}
Exemple #14
0
		private void Read(ReadStyle propertiesStyle)
		{
			// Look for an ID3v2 tag
			long id3v2_location = FindId3v2();

			if (id3v2_location >= 0)
				id3v2_tag = new Id3v2Tag(this, id3v2_location);


			// Look for an ID3v1 tag
			long id3v1_location = FindId3v1();

			if (id3v1_location >= 0)
				id3v1_tag = new Id3v1Tag(this, id3v1_location);


			// Look for an APE tag
			long ape_location = FindApe(id3v1_location >= 0);

			if (ape_location >= 0)
				ape_tag = new ApeTag(this, ape_location);


			tag.SetTags(id3v2_tag, ape_tag, id3v1_tag);

			FindMpegTag(TagTypes.Id3v2, true);

			if (propertiesStyle != ReadStyle.None)
				properties = new MpegProperties(this, propertiesStyle);
		}
Exemple #15
0
		private void Read(ReadStyle propertiesStyle)
		{
			// Look for an ID3v1 tag
			long id3v1Location = FindId3v1();

			if (id3v1Location >= 0)
			{
				id3v1Tag = new Id3v1Tag(this, id3v1Location);
			}


			// Look for an APE tag
			long apeLocation = FindApe(id3v1Location != 0);

			if (apeLocation >= 0)
				apeTag = new ApeTag(this, apeLocation);


			// Look for an ID3v2 tag
			long id3v2Location = FindId3v2();

			if (id3v2Location >= 0)
				id3v2Tag = new Id3v2Tag(this, id3v2Location);


			tag.SetTags(apeTag, id3v2Tag, id3v1Tag);
			FindMpcTag(TagTypes.Ape, true);


			// Look for MPC metadata
			Seek((id3v2Location >= 0) ? (id3v2Location + id3v2Tag.Header.CompleteTagSize) : 0);

			if (propertiesStyle != ReadStyle.None)
				properties = new MpcProperties(ReadBlock((int)MpcProperties.HeaderSize),
				   Length - Tell - apeTag.Footer.CompleteTagSize);
		}
Exemple #16
0
        public bool Strip(TagTypes types, bool freeMemory)
        {
            FileAccessMode original_mode = Mode;

            if (IsReadOnly)
            {
                TagLibDebugger.Debug("Mpeg.File.Strip() - Cannot strip tags from a read only file.");
                return(false);
            }

            try
            {
                Mode = FileAccessMode.Write;
            }
            catch (TagLibException)
            {
                TagLibDebugger.Debug("Mpeg.File.Strip() - Cannot strip tags from a read only file.");
                return(false);
            }

            if ((types & TagTypes.Id3v2) != 0)
            {
                long id3v2_location = FindId3v2();
                if (id3v2_location >= 0)
                {
                    Seek(id3v2_location);
                    Id3v2Header header = new Id3v2Header(ReadBlock((int)Id3v2Header.Size));

                    if (header.TagSize == 0)
                    {
                        TagLibDebugger.Debug("Mpc.File.Save() -- Id3v2 header is broken. Ignoring.");
                    }
                    else
                    {
                        RemoveBlock(id3v2_location, (int)header.CompleteTagSize);
                    }
                }

                if (freeMemory)
                {
                    id3v2_tag = null;
                }
            }

            long id3v1_location = FindId3v1();

            if ((types & TagTypes.Id3v1) != 0)
            {
                if (id3v1_location >= 0)
                {
                    Truncate(id3v1_location);
                    id3v1_location = -1;
                }

                if (freeMemory)
                {
                    id3v1_tag = null;
                }
            }

            if ((types & TagTypes.Ape) != 0)
            {
                long ape_location = FindApe(id3v1_location >= 0);
                if (ape_location != -1)
                {
                    Seek(ape_location);
                    int ape_size = (int)(new ApeFooter(ReadBlock((int)ApeFooter.Size))).CompleteTagSize;
                    ape_location = ape_location + ApeFooter.Size - ape_size;
                    RemoveBlock(ape_location, ape_size);
                }

                if (freeMemory)
                {
                    ape_tag = null;
                }
            }

            tag.SetTags(id3v2_tag, ape_tag, id3v1_tag);

            Mode = original_mode;
            return(true);
        }