mimit
mimit

Reputation: 39

I cannot get the name of the Artist and of the Album using WMPLib in C#

I am trying to make a music player in C# using WMPLib. Here is what I have:

WMPLib.WindowsMediaPlayer song = new WMPLib.WindowsMediaPlayer();
song.URL = file;  //the path to a mp3 file
song.controls.stop();
Console.WriteLine(song.currentMedia.getItemInfo("Title"));
Console.WriteLine(song.currentMedia.getItemInfo("Artist"));
Console.WriteLine(song.currentMedia.getItemInfo("Album"));

Only 'song.currentMedia.getItemInfo("Title")' works (it returns the title). What am I doing wrong with Artist and Album that they return ""(nothing)?

Upvotes: 2

Views: 1503

Answers (1)

mimit
mimit

Reputation: 39

I solved it! I have to wait a little for the song to load from the disk. Information like Album and Artist is available only after the song has loaded.

This was helpful: https://social.msdn.microsoft.com/Forums/en-US/7718f71a-1296-4168-9b12-36d063993b0d/getting-an-track-length-with-windows-media-player?forum=Vsexpressvcs

Upvotes: 1

Related Questions