コード例 #1
0
        public TrackFolderModel CreateTrackFromFile(string pathToTrack)
        {
            using (WaveFileReader wave = new WaveFileReader(pathToTrack))
            {
                var track = new TrackFolderModel
                {
                    Duration   = wave.TotalTime,
                    Name       = Path.GetFileNameWithoutExtension(pathToTrack),
                    PathToFile = pathToTrack,
                    Format     = MusicFormat.WAV
                };

                return(track);
            }
        }
コード例 #2
0
        public TrackFolderModel CreateTrackFromFile(string musicFile)
        {
            using (var mp3 = TagLib.File.Create(musicFile))
            {
                Tag id3Frames = mp3.GetTag(TagTypes.Id3v2);

                var track = new TrackFolderModel
                {
                    Name       = id3Frames.Title,
                    Duration   = mp3.Properties.Duration,
                    PathToFile = musicFile,
                    Album      = id3Frames.Album,
                    Artist     = id3Frames.FirstAlbumArtist,
                    Genre      = id3Frames.FirstGenre,
                    Format     = MusicFormat.MP3
                };

                return(track);
            }
        }