Esempio n. 1
0
 /// <summary>
 /// Resets the properties of the ID3v1 tag to their default values.
 /// </summary>
 public void Reset()
 {
     Title       = null;
     Artist      = null;
     Album       = null;
     Year        = null;
     Comment     = null;
     TrackNumber = null;
     GenreIndex  = 12; /* Other */
     TagVersion  = ID3v1TagVersion.ID3v11;
 }
Esempio n. 2
0
        /// <summary>
        /// Reads the ID3v1 tag from the specified stream.
        /// </summary>
        /// <param name="stream">The stream.</param>
        public void Read(Stream stream)
        {
            if (stream.Length >= 128)
            {
                stream.Seek(-128, SeekOrigin.End);

                if (GetString(stream, 3) == "TAG")
                {
                    Title  = GetString(stream, 30);
                    Artist = GetString(stream, 30);
                    Album  = GetString(stream, 30);
                    Year   = GetString(stream, 4);

                    // Comment
                    byte[] buf = new byte[30];
                    stream.Read(buf, 0, 30);
                    string comment = GetString(buf);

                    // ID3v1.1
                    if (buf[28] == 0 && buf[29] != 0)
                    {
                        TagVersion  = ID3v1TagVersion.ID3v11;
                        Comment     = GetTrimmedString(comment, 28);
                        TrackNumber = buf[29];
                    }
                    else
                    {
                        TagVersion  = ID3v1TagVersion.ID3v10;
                        Comment     = comment;
                        TrackNumber = null;
                    }

                    int genreIndex = stream.Read1();
                    if (genreIndex < 0 || genreIndex > 147)
                    {
                        genreIndex = 12; // "Other"
                    }
                    GenreIndex = genreIndex;
                }
                else
                {
                    Reset();
                }
            }
            else
            {
                Reset();
            }
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is ID3v1TagVersion)
            {
                ID3v1TagVersion tagVersion = (ID3v1TagVersion)value;
                if (tagVersion == ID3v1TagVersion.ID3v10)
                {
                    return(30);
                }
                else
                {
                    return(28);
                }
            }

            return(0);
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ID3v1Tag"/> class.
 /// </summary>
 /// <param name="stream">The stream.</param>
 public ID3v1Tag(Stream stream)
 {
     _tagVersion = ID3v1TagVersion.ID3v11;
     _genreIndex = 12; // Other
     Read(stream);
 }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ID3v1Tag"/> class.
 /// </summary>
 /// <param name="path">The full path of the file.</param>
 public ID3v1Tag(string path)
 {
     _tagVersion = ID3v1TagVersion.ID3v11;
     _genreIndex = 12; // Other
     Read(path);
 }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ID3v1Tag"/> class.
 /// </summary>
 public ID3v1Tag()
 {
     _tagVersion = ID3v1TagVersion.ID3v11;
     _genreIndex = 12; // Other
 }
Esempio n. 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ID3v1Tag"/> class.
 /// </summary>
 /// <param name="stream">The stream.</param>
 public ID3v1Tag(Stream stream)
 {
     _tagVersion = ID3v1TagVersion.ID3v11;
     _genreIndex = 12; // Other
     Read(stream);
 }
Esempio n. 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ID3v1Tag"/> class.
 /// </summary>
 /// <param name="path">The full path of the file.</param>
 public ID3v1Tag(string path)
 {
     _tagVersion = ID3v1TagVersion.ID3v11;
     _genreIndex = 12; // Other
     Read(path);
 }
Esempio n. 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ID3v1Tag"/> class.
 /// </summary>
 public ID3v1Tag()
 {
     _tagVersion = ID3v1TagVersion.ID3v11;
     _genreIndex = 12; // Other
 }