This class extends Frame to provide support ID3v2 Text Information Frames (Section 4.2), covering "T000" to "TZZZ", excluding "TXXX".

Text Information Frames contain the most commonly used values in tagging, including the artist, the track name, and just about any value that can be expressed as text.

The following table contains types and descriptions as found in the ID3 2.4.0 native frames specification. (Copyright (C) Martin Nilsson 2000.)

ID Description TIT1 The 'Content group description' frame is used if the sound belongs to a larger category of sounds/music. For example, classical music is often sorted in different musical sections (e.g. "Piano Concerto", "Weather - Hurricane"). TIT2 The 'Title/Songname/Content description' frame is the actual name of the piece (e.g. "Adagio", "Hurricane Donna"). TIT3 The 'Subtitle/Description refinement' frame is used for information directly related to the contents title (e.g. "Op. 16" or "Performed live at Wembley"). TALB The 'Album/Movie/Show title' frame is intended for the title of the recording (or source of sound) from which the audio in the file is taken. TOAL The 'Original album/movie/show title' frame is intended for the title of the original recording (or source of sound), if for example the music in the file should be a cover of a previously released song. TRCK The 'Track number/Position in set' frame is a numeric string containing the order number of the audio-file on its original recording. This MAY be extended with a "/" character and a numeric string containing the total number of tracks/elements on the original recording. E.g. "4/9". TPOS The 'Part of a set' frame is a numeric string that describes which part of a set the audio came from. This frame is used if the source described in the "TALB" frame is divided into several mediums, e.g. a double CD. The value MAY be extended with a "/" character and a numeric string containing the total number of parts in the set. E.g. "1/2". TSST The 'Set subtitle' frame is intended for the subtitle of the part of a set this track belongs to. TSRC The 'ISRC' frame should contain the International Standard Recording Code [ISRC] (12 characters). TPE1 The 'Lead artist/Lead performer/Soloist/Performing group' is used for the main artist. TPE2 The 'Band/Orchestra/Accompaniment' frame is used for additional information about the performers in the recording. TPE3 The 'Conductor' frame is used for the name of the conductor. TPE4 The 'Interpreted, remixed, or otherwise modified by' frame contains more information about the people behind a remix and similar interpretations of another existing piece. TOPE The 'Original artist/performer' frame is intended for the performer of the original recording, if for example the music in the file should be a cover of a previously released song. TEXT The 'Lyricist/Text writer' frame is intended for the writer of the text or lyrics in the recording. TOLY The 'Original lyricist/text writer' frame is intended for the text writer of the original recording, if for example the music in the file should be a cover of a previously released song. TCOM The 'Composer' frame is intended for the name of the composer. TMCL The 'Musician credits list' is intended as a mapping between instruments and the musician that played it. Every odd field is an instrument and every even is an artist or a comma delimited list of artists. TIPL The 'Involved people list' is very similar to the musician credits list, but maps between functions, like producer, and names. TENC The 'Encoded by' frame contains the name of the person or organisation that encoded the audio file. This field may contain a copyright message, if the audio file also is copyrighted by the encoder. TBPM The 'BPM' frame contains the number of beats per minute in the main part of the audio. The BPM is an integer and represented as a numerical string. TLEN The 'Length' frame contains the length of the audio file in milliseconds, represented as a numeric string. TKEY The 'Initial key' frame contains the musical key in which the sound starts. It is represented as a string with a maximum length of three characters. The ground keys are represented with "A","B","C","D","E", "F" and "G" and halfkeys represented with "b" and "#". Minor is represented as "m", e.g. "Dbm". Off key is represented with an "o" only. TLAN The 'Language' frame should contain the languages of the text or lyrics spoken or sung in the audio. The language is represented with three characters according to ISO-639-2. If more than one language is used in the text their language codes should follow according to the amount of their usage. TCON The 'Content type', which ID3v1 was stored as a one byte numeric value only, is now a string. You may use one or several of the ID3v1 types as numerical strings, or, since the category list would be impossible to maintain with accurate and up to date categories, define your own. TFLT The 'File type' frame indicates which type of audio this tag defines. (See the specification for more details.) TMED The 'Media type' frame describes from which media the sound originated. (See the specification for more details.) TMOO The 'Mood' frame is intended to reflect the mood of the audio with a few keywords, e.g. "Romantic" or "Sad". TCOP The 'Copyright message' frame, in which the string must begin with a year and a space character (making five characters), is intended for the copyright holder of the original sound, not the audio file itself. The absence of this frame means only that the copyright information is unavailable or has been removed, and must not be interpreted to mean that the audio is public domain. Every time this field is displayed the field must be preceded with "Copyright " (C) " ", where (C) is one character showing a C in a circle. TPRO The 'Produced notice' frame, in which the string must begin with a year and a space character (making five characters), is intended for the production copyright holder of the original sound, not the audio file itself. The absence of this frame means only that the production copyright information is unavailable or has been removed, and must not be interpreted to mean that the audio is public domain. Every time this field is displayed the field must be preceded with "Produced " (P) " ", where (P) is one character showing a P in a circle. TPUB The 'Publisher' frame simply contains the name of the label or publisher. TOWN The 'File owner/licensee' frame contains the name of the owner or licensee of the file and it's contents. TRSN The 'Internet radio station name' frame contains the name of the internet radio station from which the audio is streamed. TRSO The 'Internet radio station owner' frame contains the name of the owner of the internet radio station from which the audio is streamed. TOFN The 'Original filename' frame contains the preferred filename for the file, since some media doesn't allow the desired length of the filename. The filename is case sensitive and includes its suffix. TDLY The 'Playlist delay' defines the numbers of milliseconds of silence that should be inserted before this audio. The value zero indicates that this is a part of a multifile audio track that should be played continuously. TDEN The 'Encoding time' frame contains a timestamp describing when the audio was encoded. Timestamp format is described in the ID3v2 structure document. TDOR The 'Original release time' frame contains a timestamp describing when the original recording of the audio was released. Timestamp format is described in the ID3v2 structure document. TDRC The 'Recording time' frame contains a timestamp describing when the audio was recorded. Timestamp format is described in the ID3v2 structure document. TDRL The 'Release time' frame contains a timestamp describing when the audio was first released. Timestamp format is described in the ID3v2 structure document. TDTG The 'Tagging time' frame contains a timestamp describing then the audio was tagged. Timestamp format is described in the ID3v2 structure document. TSSE The 'Software/Hardware and settings used for encoding' frame includes the used audio encoder and its settings when the file was encoded. Hardware refers to hardware encoders, not the computer on which a program was run. TSOA The 'Album sort order' frame defines a string which should be used instead of the album name (TALB) for sorting purposes. E.g. an album named "A Soundtrack" might preferably be sorted as "Soundtrack". TSOP The 'Performer sort order' frame defines a string which should be used instead of the performer (TPE2) for sorting purposes. TSOT The 'Title sort order' frame defines a string which should be used instead of the title (TIT2) for sorting purposes.
Наследование: TagLib.Id3v2.Frame
Пример #1
0
        public static TextInformationFrame Get(Tag tag, ByteVector ident, StringType encoding, bool create)
        {
            if (tag == null)
            {
                throw new ArgumentNullException("tag");
            }
            if (ident == null)
            {
                throw new ArgumentNullException("ident");
            }
            if (ident.Count != 4)
            {
                throw new ArgumentException("Identifier must be four bytes long.", "ident");
            }
            foreach (TextInformationFrame frame in tag.GetFrames <TextInformationFrame>(ident))
            {
                return(frame);
            }
            if (!create)
            {
                return(null);
            }
            TextInformationFrame new_frame = new TextInformationFrame(ident, encoding);

            tag.AddFrame(new_frame);
            return(new_frame);
        }
Пример #2
0
        public override Frame Clone()
        {
            TextInformationFrame frame = (this is UserTextInformationFrame)?new UserTextInformationFrame(null, encoding):new TextInformationFrame(FrameId, encoding);

            frame.text_fields = (string[])text_fields.Clone();
            if (raw_data != null)
            {
                frame.raw_data = new ByteVector(raw_data);
            }
            frame.raw_version = raw_version;
            return(frame);
        }
Пример #3
0
        public string GetTextAsString(ByteVector ident)
        {
            Frame frame;

            if (ident[0] == 'W')
            {
                frame = UrlLinkFrame.Get(this, ident, false);
            }
            else
            {
                frame = TextInformationFrame.Get(this, ident, false);
            }
            string result = frame == null?null:frame.ToString();

            return(string.IsNullOrEmpty(result)?null:result);
        }
        public override ByteVector Render(byte version)
        {
            if (version != 3 || FrameId != FrameType.TDRC)
            {
                return(base.Render(version));
            }

            string text = ToString();

            if (text.Length < 10 || text [4] != '-' ||
                text [7] != '-')
            {
                return(base.Render(version));
            }

            ByteVector           output = new ByteVector();
            TextInformationFrame f;

            f      = new TextInformationFrame(FrameType.TYER, encoding);
            f.Text = new string [] { text.Substring(0, 4) };
            output.Add(f.Render(version));

            f      = new TextInformationFrame(FrameType.TDAT, encoding);
            f.Text = new string [] {
                text.Substring(5, 2) + text.Substring(8, 2)
            };
            output.Add(f.Render(version));

            if (text.Length < 16 || text [10] != 'T' ||
                text [13] != ':')
            {
                return(output);
            }

            f      = new TextInformationFrame(FrameType.TIME, encoding);
            f.Text = new string [] {
                text.Substring(11, 2) + text.Substring(14, 2)
            };
            output.Add(f.Render(version));

            return(output);
        }
Пример #5
0
        public void SetTextFrame(ByteVector ident, params string[] text)
        {
            if (ident == null)
            {
                throw new ArgumentNullException("ident");
            }
            if (ident.Count != 4)
            {
                throw new ArgumentException("Identifier must be four bytes long.", "ident");
            }
            bool empty = true;

            if (text != null)
            {
                for (int i = 0; empty && i < text.Length; i++)
                {
                    if (!string.IsNullOrEmpty(text[i]))
                    {
                        empty = false;
                    }
                }
            }
            if (empty)
            {
                RemoveFrames(ident);
                return;
            }
            if (ident[0] == 'W')
            {
                UrlLinkFrame urlFrame = UrlLinkFrame.Get(this, ident, true);
                urlFrame.Text         = text;
                urlFrame.TextEncoding = DefaultEncoding;
                return;
            }
            TextInformationFrame frame = TextInformationFrame.Get(this, ident, true);

            frame.Text         = text;
            frame.TextEncoding = DefaultEncoding;
        }
		public override Frame Clone ()
		{
			TextInformationFrame frame = new TextInformationFrame (
				FrameId, encoding);
			frame.text_fields = (string[]) text_fields.Clone ();
			if (raw_data != null)
				frame.raw_data = new ByteVector (raw_data);
			frame.raw_version = raw_version;
			return frame;
		}
		/// <summary>
		///    Gets a <see cref="TextInformationFrame" /> object of a
		///    specified type from a specified tag, optionally creating
		///    and adding one with a specified encoding if none is
		///    found.
		/// </summary>
		/// <param name="tag">
		///    A <see cref="Tag" /> object to search for the specified
		///    tag in.
		/// </param>
		/// <param name="ident">
		///    A <see cref="ByteVector" /> object containing the frame
		///    identifer to search for.
		/// </param>
		/// <param name="encoding">
		///    A <see cref="StringType" /> value specifying the encoding
		///    to use if a new frame is created.
		/// </param>
		/// <param name="create">
		///    A <see cref="bool" /> value specifying whether or not to
		///    create a new frame if an existing frame was not found.
		/// </param>
		/// <returns>
		///    A <see cref="TextInformationFrame" /> object containing
		///    the frame found in or added to <paramref name="tag" /> or
		///    <see langref="null" /> if no value was found <paramref
		///    name="create" /> is <see langref="false" />.
		/// </returns>
		/// <remarks>
		///    To create a frame without having to specify the encoding,
		///    use <see cref="Get(Tag,ByteVector,bool)" />.
		/// </remarks>
		/// <exception cref="ArgumentNullException">
		///    <paramref name="tag" /> or <paramref name="type" /> is
		///    <see langref="null" />.
		/// </exception>
		/// <exception cref="ArgumentException">
		///    <paramref name="type" /> is not exactly four bytes long.
		/// </exception>
		public static TextInformationFrame Get (Tag tag,
		                                        ByteVector ident,
		                                        StringType encoding,
		                                        bool create)
		{
			if (tag == null)
				throw new ArgumentNullException ("tag");
			
			if (ident == null)
				throw new ArgumentNullException ("ident");
			
			if (ident.Count != 4)
				throw new ArgumentException (
					"Identifier must be four bytes long.",
					"ident");
			
			foreach (TextInformationFrame frame in
				tag.GetFrames<TextInformationFrame> (ident))
				return frame;
			
			if (!create)
				return null;
			
			TextInformationFrame new_frame =
				new TextInformationFrame (ident, encoding);
			tag.AddFrame (new_frame);
			return new_frame;
		}
		public override ByteVector Render (byte version)
		{
			if (version != 3 || FrameId != FrameType.TDRC)
				return base.Render (version);
			
			string text = ToString ();
			if (text.Length < 10 || text [4] != '-' ||
				text [7] != '-')
				return base.Render (version);
			
			ByteVector output = new ByteVector ();
			TextInformationFrame f;
			
			f = new TextInformationFrame (FrameType.TYER, encoding);
			f.Text = new string [] {text.Substring (0, 4)};
			output.Add (f.Render (version));
			
			f = new TextInformationFrame (FrameType.TDAT, encoding);
			f.Text = new string [] {
				text.Substring (5, 2) + text.Substring (8, 2)
			};
			output.Add (f.Render (version));
			
			if (text.Length < 16 || text [10] != 'T' ||
				text [13] != ':')
				return output;
			
			f = new TextInformationFrame (FrameType.TIME, encoding);
			f.Text = new string [] {
				text.Substring (11, 2) + text.Substring (14, 2)
			};
			output.Add (f.Render (version));
			
			return output;
		}
Пример #9
0
		public void TestTextInformationFrame ()
		{
			ByteVector id = "TPE2";
			TextInformationFrame frame = new TextInformationFrame (id);
			frame.Text = val_mult;
			
			FrameTest (frame, 2,
				delegate (Frame f, StringType e) {
					(f as TextInformationFrame).TextEncoding = e;
				},
				
				delegate (ByteVector d, byte v) {
					return new TextInformationFrame (d, v);
				},
				
				delegate (Frame f, string m) {
					TextInformationFrame g = (f as TextInformationFrame);
					Assert.AreEqual (id, g.FrameId, m);
					Assert.AreEqual (val_mult.Length, g.Text.Length, m);
					for (int i = 0; i < val_mult.Length; i ++) {
						Assert.AreEqual (val_mult [i], g.Text [i], m);
					}
				});
		}
 public static TextInformationFrame Get(TagLib.Id3v2.Tag tag, ByteVector ident, StringType encoding, bool create)
 {
     if (tag == null)
     {
         throw new ArgumentNullException("tag");
     }
     if (ident == null)
     {
         throw new ArgumentNullException("ident");
     }
     if (ident.Count != 4)
     {
         throw new ArgumentException("Identifier must be four bytes long.", "ident");
     }
     IEnumerator<TextInformationFrame> enumerator = tag.GetFrames<TextInformationFrame>(ident).GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             return enumerator.Current;
         }
     }
     finally
     {
         if (enumerator == null)
         {
         }
         enumerator.Dispose();
     }
     if (!create)
     {
         return null;
     }
     TextInformationFrame frame = new TextInformationFrame(ident, encoding);
     tag.AddFrame(frame);
     return frame;
 }
 public override ByteVector Render(byte version)
 {
     if ((version != 3) || (base.FrameId != FrameType.TDRC))
     {
         return base.Render(version);
     }
     string str = this.ToString();
     if (((str.Length < 10) || (str[4] != '-')) || (str[7] != '-'))
     {
         return base.Render(version);
     }
     ByteVector vector = new ByteVector();
     TextInformationFrame frame = new TextInformationFrame(FrameType.TYER, this.encoding);
     frame.Text = new string[] { str.Substring(0, 4) };
     vector.Add(frame.Render(version));
     frame = new TextInformationFrame(FrameType.TDAT, this.encoding);
     frame.Text = new string[] { str.Substring(5, 2) + str.Substring(8, 2) };
     vector.Add(frame.Render(version));
     if (((str.Length >= 0x10) && (str[10] == 'T')) && (str[13] == ':'))
     {
         frame = new TextInformationFrame(FrameType.TIME, this.encoding);
         frame.Text = new string[] { str.Substring(11, 2) + str.Substring(14, 2) };
         vector.Add(frame.Render(version));
     }
     return vector;
 }
Пример #12
0
        private string[] GetTextAsArray(ByteVector ident)
        {
            TextInformationFrame frame = TextInformationFrame.Get(this, ident, false);

            return(frame == null?new string[0]:frame.Text);
        }
Пример #13
0
        protected void Parse(ByteVector data)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            bool fullTagUnsynch = (header.MajorVersion < 4) && ((header.Flags & HeaderFlags.Unsynchronisation) != 0);

            if (fullTagUnsynch)
            {
                SynchData.ResynchByteVector(data);
            }
            int frame_data_position = 0;
            int frame_data_length   = data.Count;

            if ((header.Flags & HeaderFlags.ExtendedHeader) != 0)
            {
                extended_header = new ExtendedHeader(data, header.MajorVersion);
                if (extended_header.Size <= data.Count)
                {
                    frame_data_position += (int)extended_header.Size;
                    frame_data_length   -= (int)extended_header.Size;
                }
            }
            TextInformationFrame tdrc = null;
            TextInformationFrame tyer = null;
            TextInformationFrame tdat = null;
            TextInformationFrame time = null;

            while (frame_data_position < frame_data_length - FrameHeader.Size(header.MajorVersion))
            {
                if (data[frame_data_position] == 0)
                {
                    break;
                }
                Frame frame = null;
                try
                {
                    frame = FrameFactory.CreateFrame(data, ref frame_data_position, header.MajorVersion, fullTagUnsynch);
                }
                catch (NotImplementedException)
                {
                    continue;
                }
                catch (CorruptFileException)
                {
                    continue;
                }
                if (frame == null)
                {
                    break;
                }
                if (frame.Size == 0)
                {
                    continue;
                }
                AddFrame(frame);
                if (header.MajorVersion == 4)
                {
                    continue;
                }
                if (tdrc == null && frame.FrameId.Equals(FrameType.TDRC))
                {
                    tdrc = frame as TextInformationFrame;
                }
                else if (tyer == null && frame.FrameId.Equals(FrameType.TYER))
                {
                    tyer = frame as TextInformationFrame;
                }
                else if (tdat == null && frame.FrameId.Equals(FrameType.TDAT))
                {
                    tdat = frame as TextInformationFrame;
                }
                else if (time == null && frame.FrameId.Equals(FrameType.TIME))
                {
                    time = frame as TextInformationFrame;
                }
            }
            if (tdrc == null || tdat == null || tdrc.ToString().Length > 4)
            {
                return;
            }
            string year = tdrc.ToString();

            if (year.Length != 4)
            {
                return;
            }
            StringBuilder tdrc_text = new StringBuilder();

            tdrc_text.Append(year);
            if (tdat != null)
            {
                string tdat_text = tdat.ToString();
                if (tdat_text.Length == 4)
                {
                    tdrc_text.Append("-").Append(tdat_text, 0, 2).Append("-").Append(tdat_text, 2, 2);
                    if (time != null)
                    {
                        string time_text = time.ToString();
                        if (time_text.Length == 4)
                        {
                            tdrc_text.Append("T").Append(time_text, 0, 2).Append(":").Append(time_text, 2, 2);
                        }
                        RemoveFrames(FrameType.TIME);
                    }
                }
                RemoveFrames(FrameType.TDAT);
            }
            tdrc.Text = new string[]
            {
                tdrc_text.ToString()
            };
        }