예제 #1
0
        public static SimpleTag FromFile(string fileName)
        {
            SimpleTag result = new SimpleTag();
            TagBase   tag    = new TagBase();

            tag.ReadFromFile(fileName, new Achamenes.ID3.Frames.Parsers.FrameParserFactory());
            foreach (Frames.Frame frame in tag.Frames)
            {
                if (frame is Frames.PictureFrame)
                {
                    if (((Frames.PictureFrame)frame).PictureType == PictureType.CoverFront)
                    {
                        result.CoverArt = ((Frames.PictureFrame)frame).Picture;
                    }
                    else if (result.CoverArt == null)
                    {
                        result.CoverArt = ((Frames.PictureFrame)frame).Picture;
                    }
                }
                else if (frame is Frames.ArtistTextFrame)
                {
                    result.Artist = ((Frames.ArtistTextFrame)frame).Text;
                }
                else if (frame is Frames.AlbumTextFrame)
                {
                    result.Album = ((Frames.AlbumTextFrame)frame).Text;
                }
                else if (frame is Frames.CommentExtendedTextFrame)
                {
                    result.Comment = ((Frames.CommentExtendedTextFrame)frame).Text;
                }
                else if (frame is Frames.ComposerTextFrame)
                {
                    result.Composer = ((Frames.ComposerTextFrame)frame).Text;
                }
                else if (frame is Frames.CopyrightTextFrame)
                {
                    result.Copyright = ((Frames.CopyrightTextFrame)frame).Text;
                }
                else if (frame is Frames.EncodedByTextFrame)
                {
                    result.EncodedBy = ((Frames.EncodedByTextFrame)frame).Text;
                }
                else if (frame is Frames.GenreTextFrame)
                {
                    StandardGenreManager manager = new StandardGenreManager();
                    result.Genre = manager.TranslateToUserFriendly(((Frames.GenreTextFrame)frame).Text);
                }
                else if (frame is Frames.GroupingTextFrame)
                {
                    result.Grouping = ((Frames.GroupingTextFrame)frame).Text;
                }
                else if (frame is Frames.LyricsExtendedTextFrame)
                {
                    result.Lyrics = ((Frames.LyricsExtendedTextFrame)frame).Text;
                }
                else if (frame is Frames.OriginalArtistTextFrame)
                {
                    result.OriginalArtist = ((Frames.OriginalArtistTextFrame)frame).Text;
                }
                else if (frame is Frames.TitleTextFrame)
                {
                    result.Title = ((Frames.TitleTextFrame)frame).Text;
                }
                else if (frame is Frames.CustomUserUrlFrame)
                {
                    result.UserUrl = ((Frames.CustomUserUrlFrame)frame).Url;
                }
                else if (frame is Frames.OfficialArtistUrlFrame)
                {
                    result.ArtistUrl = ((Frames.OfficialArtistUrlFrame)frame).Url;
                }
                else if (frame is Frames.TrackTextFrame)
                {
                    result.TrackNumber = ((Frames.TrackTextFrame)frame).TrackNumber;
                    result.TotalTracks = ((Frames.TrackTextFrame)frame).TotalTracks;
                }
                else if (frame is Frames.PartOfSetTextFrame)
                {
                    result.PartNumber = ((Frames.PartOfSetTextFrame)frame).PartNumber;
                    result.TotalParts = ((Frames.PartOfSetTextFrame)frame).TotalParts;
                }
                else if (frame is Frames.YearTextFrame)
                {
                    string year = ((Frames.YearTextFrame)frame).Text;
                    if (year != "")
                    {
                        result.Year = year.Substring(0, 4);
                    }
                }
                else if (frame is Frames.ReleaseTimeTextFrame)
                {
                    string year = ((Frames.ReleaseTimeTextFrame)frame).Text;
                    if (year != "")
                    {
                        result.Year = year.Substring(0, 4);
                    }
                }
                else if (frame is Frames.BeatsPerMinuteTextFrame)
                {
                    result.BPM = int.Parse((((Frames.BeatsPerMinuteTextFrame)frame).Text));
                }
            }

            return(result);
        }
예제 #2
0
파일: SimpleTag.cs 프로젝트: sahands/a-id3
        public static SimpleTag FromFile(string fileName)
        {
            SimpleTag result=new SimpleTag();
            TagBase tag=new TagBase();
            tag.ReadFromFile(fileName, new Achamenes.ID3.Frames.Parsers.FrameParserFactory());
            foreach(Frames.Frame frame in tag.Frames)
            {
                if(frame is Frames.PictureFrame)
                {
                    if(((Frames.PictureFrame)frame).PictureType==PictureType.CoverFront)
                        result.CoverArt=((Frames.PictureFrame)frame).Picture;
                    else if(result.CoverArt==null)
                        result.CoverArt=((Frames.PictureFrame)frame).Picture;
                }
                else if(frame is Frames.ArtistTextFrame)
                    result.Artist=((Frames.ArtistTextFrame)frame).Text;
                else if(frame is Frames.AlbumTextFrame)
                    result.Album=((Frames.AlbumTextFrame)frame).Text;
                else if(frame is Frames.CommentExtendedTextFrame)
                    result.Comment=((Frames.CommentExtendedTextFrame)frame).Text;
                else if(frame is Frames.ComposerTextFrame)
                    result.Composer=((Frames.ComposerTextFrame)frame).Text;
                else if(frame is Frames.CopyrightTextFrame)
                    result.Copyright=((Frames.CopyrightTextFrame)frame).Text;
                else if(frame is Frames.EncodedByTextFrame)
                    result.EncodedBy=((Frames.EncodedByTextFrame)frame).Text;
                else if(frame is Frames.GenreTextFrame)
                {
                    StandardGenreManager manager=new StandardGenreManager();
                    result.Genre=manager.TranslateToUserFriendly(((Frames.GenreTextFrame)frame).Text);
                }
                else if(frame is Frames.GroupingTextFrame)
                    result.Grouping=((Frames.GroupingTextFrame)frame).Text;
                else if(frame is Frames.LyricsExtendedTextFrame)
                    result.Lyrics=((Frames.LyricsExtendedTextFrame)frame).Text;
                else if(frame is Frames.OriginalArtistTextFrame)
                    result.OriginalArtist=((Frames.OriginalArtistTextFrame)frame).Text;
                else if(frame is Frames.TitleTextFrame)
                    result.Title=((Frames.TitleTextFrame)frame).Text;
                else if(frame is Frames.CustomUserUrlFrame)
                    result.UserUrl=((Frames.CustomUserUrlFrame)frame).Url;
                else if(frame is Frames.OfficialArtistUrlFrame)
                    result.ArtistUrl=((Frames.OfficialArtistUrlFrame)frame).Url;
                else if(frame is Frames.TrackTextFrame)
                {
                    result.TrackNumber=((Frames.TrackTextFrame)frame).TrackNumber;
                    result.TotalTracks=((Frames.TrackTextFrame)frame).TotalTracks;
                }
                else if(frame is Frames.PartOfSetTextFrame)
                {
                    result.PartNumber=((Frames.PartOfSetTextFrame)frame).PartNumber;
                    result.TotalParts=((Frames.PartOfSetTextFrame)frame).TotalParts;
                }
                else if(frame is Frames.YearTextFrame)
                {
                    string year=((Frames.YearTextFrame)frame).Text;
                    if(year!="")
                        result.Year=year.Substring(0, 4);
                }
                else if(frame is Frames.ReleaseTimeTextFrame)
                {
                    string year=((Frames.ReleaseTimeTextFrame)frame).Text;
                    if(year!="")
                        result.Year=year.Substring(0, 4);
                }
                else if(frame is Frames.BeatsPerMinuteTextFrame)
                {
                    result.BPM=int.Parse((((Frames.BeatsPerMinuteTextFrame)frame).Text));
                }
            }

            return result;
        }