문제

I'm making a music player of sorts using c# and I've gotten songs to play/pause, fast forward/rewind and etc functions. The only thing I'm having trouble finding a solution to is displaying the song name, artist, album, and album art on a picturebox. I've heard of taglib# but I haven't found a clear way to implement/work with it. If there are other solutions I'm open to those as well.

I'm using the WindowsMediaPlayer class object too, but it doesn't display the album or artist, only the song name.

도움이 되었습니까?

해결책

Here's a code snippet that shows how you can get the information you're looking for.

    TagLib.File tagFile = TagLib.File.Create(@"C:\MySong.mp3");

    uint trackNumber = tagFile.Tag.Track;
    string songTitle = tagFile.Tag.Title;
    string artist = tagFile.Tag.AlbumArtists.FirstOrDefault();
    string albumTitle = tagFile.Tag.Album;
    uint year = tagFile.Tag.Year;
    string genre = tagFile.Tag.Genres.FirstOrDefault();

    MemoryStream ms = new MemoryStream(tagFile.Tag.Pictures[0].Data.Data);
    System.Drawing.Image albumArt = System.Drawing.Image.FromStream(ms);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top