Get Song Currently Playing In Windows Media Player

寵の児 提交于 2019-12-06 07:23:33

问题


Using C# how can I get the name of the song, artists etc that is currently playing in Windows Media Player? Applications like MSN Messenger / Google Talk do this. Thanks


回答1:


For C#

I spent hours trying to get it to work for my program. Finally I figured it out.

This solution is assuming you have either the windows media player control ON a form in your project or have created the object through code..

  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");
    

it was so simple i slapped myself when i finished, and seeing as i couldnt find the answer anywhere, i have provided it for the next guy.




回答2:


You need to use Wmp.dll.

This link will also be helpful:

http://msdn.microsoft.com/en-us/library/dd563844(VS.85).aspx



来源:https://stackoverflow.com/questions/1140560/get-song-currently-playing-in-windows-media-player

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!