I have an m3u playlist and would like to obtain tag information for every audio file in the playlist.
Using WMPLib (Windows Media Player COM object) gets me most of the way there, but I can never get tag info for the first item in the playlist. I've tried this with multiple files, so it isn't a corrupt tag issue.
Here's my code:
String testUrl = @"F:\myfiles\google drive\Google Drive\sync\music\ckcu\2013_11_10\fd3.m3u";
WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer();
player.settings.mute = true;
player.URL = testUrl;
IWMPPlaylist playlist = player.currentPlaylist;
TextBoxMain.Text += playlist.count + " items in playlist\r\n";
for (int i = 0; i < playlist.count; i++)
{
IWMPMedia2 media = (IWMPMedia2) playlist.Item[i];
// TextBoxMain.Text += media.getItemInfo("artist") + "\t" + media.getItemInfo("album") + "\t" + media.getItemInfo("name") + "\r\n";
TextBoxMain.Text += "---------- Track " + i + "-------------\r\n";
for (int j = 0; j < media.attributeCount; j++)
{
TextBoxMain.Text += media.getAttributeName(j) + " = " + media.getItemInfo(media.getAttributeName(j)) + "\r\n" ;
}
}
The output of the tool looks like this:
23 items in playlist
---------- Track 0-------------
SourceURL = F:\myfiles\google drive\Google Drive\sync\music\ckcu\2013_11_10\Amadou & Mariam - 06 - C'est Pas Facile Pour Les Aigles (Feat. Ebony Bones).mp3
---------- Track 1-------------
AcquisitionTime = 11/9/2013 5:09:49 PM
AcquisitionTimeDay = 9
AcquisitionTimeMonth = 11
AcquisitionTimeYear = 2013
AcquisitionTimeYearMonth = 11/9/2013
AcquisitionTimeYearMonthDay = 11/9/2013
AlbumID = You Have Already Gone to the Other WorldA Hawk And A Hacksaw
AlbumIDAlbumArtist = You Have Already Gone to the Other World*;*A Hawk And A Hacksaw
AudioFormat = {00000055-0000-0010-8000-00AA00389B71}
Author = A Hawk And A Hacksaw
AverageLevel =
<snip>
---------- Track 22-------------
Author = Zeep
CurrentBitrate =
Duration = 178.964
FileSize = 4630801
Is_Protected = False
IsVBR = True
SourceURL = F:\myfiles\google drive\Google Drive\sync\music\ckcu\2013_11_10\Zeep - 02 - Keep an Eye on Love.mp3
Title = Keep an Eye on Love
WM/AlbumArtist = Various Artists
WM/AlbumTitle = Far Out Bossa Nova
WM/Genre = Reggae
WM/GenreID =
WM/PartOfSet = 1/1
WM/TrackNumber = 2
WM/Year = 2008
For some reason, track 0 never has any useful attributes. I tried skipping to the next song, and when I do this, neither track 0 nor track 1 have any useful attributes.
I think I'm missing something simple here. Any thoughts?