Ejemplo n.º 1
0
        public MusicID3Tag GetTags(string filePath)
        {
            MusicID3Tag tags = null;

            using (FileStream fs = File.OpenRead(filePath))
            {
                if (fs.Length >= 128)
                {
                    MusicID3TagByte tag = new MusicID3TagByte();
                    fs.Seek(-128, SeekOrigin.End);
                    fs.Read(tag.TAGID, 0, tag.TAGID.Length);
                    fs.Read(tag.Title, 0, tag.Title.Length);
                    fs.Read(tag.Artist, 0, tag.Artist.Length);
                    fs.Read(tag.Album, 0, tag.Album.Length);
                    fs.Read(tag.Year, 0, tag.Year.Length);
                    fs.Read(tag.Comment, 0, tag.Comment.Length);
                    fs.Read(tag.Genre, 0, tag.Genre.Length);
                    string theTAGID = Encoding.Default.GetString(tag.TAGID);

                    if (theTAGID.Equals("TAG"))
                    {
                        tags         = new MusicID3Tag();
                        tags.Title   = Encoding.Default.GetString(tag.Title).Replace("\0", "");
                        tags.Artist  = Encoding.Default.GetString(tag.Artist).Replace("\0", "");
                        tags.Album   = Encoding.Default.GetString(tag.Album).Replace("\0", "");
                        tags.Year    = Encoding.Default.GetString(tag.Year).Replace("\0", "");
                        tags.Comment = Encoding.Default.GetString(tag.Comment).Replace("\0", "");
                        tags.Genre   = Encoding.Default.GetString(tag.Genre).Replace("\0", "");
                    }
                }
            }
            return(tags);
        }
Ejemplo n.º 2
0
        public MusicID3Tag GetTags(string filePath)
        {
            MusicID3Tag tags = null;
            using (FileStream fs = File.OpenRead(filePath))
            {
                if (fs.Length >= 128)
                {
                    MusicID3TagByte tag = new MusicID3TagByte();
                    fs.Seek(-128, SeekOrigin.End);
                    fs.Read(tag.TAGID, 0, tag.TAGID.Length);
                    fs.Read(tag.Title, 0, tag.Title.Length);
                    fs.Read(tag.Artist, 0, tag.Artist.Length);
                    fs.Read(tag.Album, 0, tag.Album.Length);
                    fs.Read(tag.Year, 0, tag.Year.Length);
                    fs.Read(tag.Comment, 0, tag.Comment.Length);
                    fs.Read(tag.Genre, 0, tag.Genre.Length);
                    string theTAGID = Encoding.Default.GetString(tag.TAGID);

                    if (theTAGID.Equals("TAG"))
                    {
                        tags = new MusicID3Tag();
                        tags.Title = Encoding.Default.GetString(tag.Title).Replace("\0", "");
                        tags.Artist = Encoding.Default.GetString(tag.Artist).Replace("\0", "");
                        tags.Album = Encoding.Default.GetString(tag.Album).Replace("\0", "");
                        tags.Year = Encoding.Default.GetString(tag.Year).Replace("\0", "");
                        tags.Comment = Encoding.Default.GetString(tag.Comment).Replace("\0", "");
                        tags.Genre = Encoding.Default.GetString(tag.Genre).Replace("\0", "");
                    }
                }
            }
            return tags;
        }