我有一个m3u播放列表,并希望获取播放列表中每个音频文件的标记信息。
使用WMPLib(Windows Media Player 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
由于某种原因,曲目0永远不会有任何有用的属性。我试着跳到下一首歌,当我这样做时,曲目0和曲目1都没有任何有用的属性。
我想我在这里缺少一些简单的东西。有什么想法吗?