0

c#.netのsongsフォルダーにあるすべての曲のxmlファイルを作成しています。コードは次のとおりです。

 Microsoft.MediaPlayer.Interop.IWMPMedia mediafilesinformation = plist.get_Item(i);
                   mediafilesinformation = obj_wmp.newMedia(filepath);
                    Filename = mediafilesinformation.getItemInfo("SourceURL");
                    Tracknumber = mediafilesinformation.getItemInfo("WM/TrackNumber");
                    Genre = mediafilesinformation.getItemInfo("WM/Genre");
                    Album = mediafilesinformation.getItemInfo("WM/AlbumTitle");
                    Artist = mediafilesinformation.getItemInfo("Artist");
                    Name = mediafilesinformation.getItemInfo("Name");
                    Duration = double.Parse(mediafilesinformation.getItemInfo("Duration"));

Nameで曲のタイトルを取得していますが、曲の名前を取得する必要があります。解決策を提案してください。

4

2 に答える 2

0

プロパティのName属性は、必要に応じてFileNameを指し、ファイルパス文字列を使用できます。

string fileName = Path.GetFileName(filepath);

また、すべての属性を印刷してデバッグし、属性によって保持されている値を確認することもできます。Media.getAttributeNameメソッドを使用します。同じリンクの例を以下に示します。

// Store the current media object.
var cm = Player.currentMedia;

// Get the number of attributes for the current media. 
var atCount = cm.attributeCount;

// Loop through the attribute list.
for(var i=0; i < atCount; i++){

   // Print each attribute index and name.   
   myText.value += "Attribute " + i +": ";
   myText.value += cm.getAttributeName(i);
   myText.value += "\n";
}
于 2012-04-21T10:07:14.830 に答える
0

これらのリファレンス リンクとコード スニペットに従ってください。

参照:クリップを実際に再生せずにオーディオまたはビデオ クリップの長さを取得する

Microsoft.MediaPlayer.Interop.IWMPMedia m = Player.newMedia(fileName);

string currentArtist = m.getItemInfo("Author").Trim();
string currentAlbum = m.getItemInfo("Album").Trim();
string currentTitle = m.getItemInfo("Title").Trim();
double duration = m.duration; 

参照:リンク

Microsoft.MediaPlayer.Interop.IWMPPlaylist plist; 
plist = x.mediaCollection.getAll();                        

for(int i=0; i < plist.count;i++) 
{ 
        Microsoft.MediaPlayer.Interop.IWMPMedia elem = plist.get_Item(i); 

        Response.Write(string.Format("{1} - {2} - {3} - {4} - {5}
", 
                elem.sourceURL, 
                elem.name, 
                elem.getItemInfo("MediaType"), 
                elem.getItemInfo("FileType"), 
                elem.getItemInfo("WM/TrackNumber"), 
                elem.getItemInfo("Author"), 
                elem.getItemInfo("Title") 
        )); 
} 
于 2012-04-21T10:24:04.090 に答える