获取Windows Media Player当前播放的歌曲

4

使用C#,如何获取当前在Windows Media Player中播放的歌曲名称、艺术家等信息?像MSN Messenger / Google Talk这样的应用程序可以实现此功能。谢谢

2个回答

3

对于C#

我花了好几个小时来尝试让它在我的程序中运行。 最终,我找到了解决方法。

这个解决方案假设您的项目中有Windows Media Player控件或者已通过代码创建了该对象。

  1. create a new Windows Media Player Song object and point it to a file
  2. create a string to hold your artist, then pull the artist info from the song object
  3. create a string to hold your title, then pull the artist info from the song object.

            WMPLib.IWMPMedia song = wmp.newMedia(@"C:\SongName.mp3");         
            string tmpArtist = song.getItemInfo("Artist");
            string tmpTitle = song.getItemInfo("Title");
    

当我完成后,我觉得这很简单,甚至打了自己一下。但是由于我在其他地方找不到答案,所以我把它提供给了下一个人。


1
这似乎无法获取 WMP 中当前播放的歌曲。 - Epoc

2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接