Search code examples
c#windows-media-player

Get Song Currently Playing In Windows Media Player


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


Solution

  • 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.