private void MediaPropertiesMenuItem_Click(object sender, RoutedEventArgs e) { // display the music and video elements properties String location = dlg.FileName.ToString(); MusicID3Tag musicTag = new MusicID3Tag(location); FileInfo fileInfo = new FileInfo(location); long f = fileInfo.Length; TimeSpan ts = videoMediaElement.NaturalDuration.TimeSpan; // Title, Location, FileSize, Length, // if mp3 file is currently playing show properties of file if (dlg.FileName.Substring(dlg.FileName.Length - 3) == "mp3") { MessageBox.Show(musicTag.GetMP3Info()); } // if video is present show properties of video else { MessageBox.Show("Title: " + fileInfo.Name + "\n" + "Location: " + location + "\n" + "File Size: " + f + "\n" + "Length:" + String.Format("{0:00}:{1:00}:{2:00}", ts.Hours, ts.Minutes, ts.Seconds) + System.Environment.NewLine); } }
public String GetMP3Info() { String path = this.filePath; String allInfo = ""; if (fs.Length >= 128) { MusicID3Tag tag = new MusicID3Tag(path); 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")) { string Title = Encoding.Default.GetString(tag.Title); string Artist = Encoding.Default.GetString(tag.Artist); string Album = Encoding.Default.GetString(tag.Album); string Year = Encoding.Default.GetString(tag.Year); string Comment = Encoding.Default.GetString(tag.Comment); string Genre = Encoding.Default.GetString(tag.Genre); Console.WriteLine(Title); Console.WriteLine(Artist); Console.WriteLine(Album); Console.WriteLine(Year); Console.WriteLine(Comment); Console.WriteLine(Genre); Console.WriteLine(); allInfo = "Title: " + Title + System.Environment.NewLine + "Artist: " + Artist + System.Environment.NewLine + "Album: " + Album + System.Environment.NewLine + "Year: " + Year + System.Environment.NewLine + "Comment: " + Comment + System.Environment.NewLine + "Genre: " + Genre; } } return(allInfo); }