我有一个 m3u 播放列表,想获取播放列表中每个音频文件的标签信息。
使用 WMPLib(Windows 媒体播放器 COM 对象)可以让我大部分时间到达那里,但我永远无法获得播放列表中第一项的标签信息。我已经用多个文件尝试过这个,所以这不是一个损坏的标签问题。
这是我的代码:
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" ;
}
}
该工具的输出如下所示:
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
出于某种原因,track 0 从来没有任何有用的属性。我尝试跳到下一首歌曲,当我这样做时,曲目 0 和曲目 1 都没有任何有用的属性。
我想我在这里遗漏了一些简单的东西。有什么想法吗?