Search code examples
c#windows-media-player

Access the Windows Media Player library C#


I am trying to find out how to access the Windows Media Player library in c#. I have had a look around the web and SO and have found many articles on controlling WMP. I am trying to access its library information however. I.e. its track names, file path and metadata.

Is there a library for this or at least does it store it in some form of database somewhere?

Thanks, Ben


Solution

  • Create a windows form and place a WMP component on it, named WMPLayer:

    AxWMPLib.AxWindowsMediaPlayer Player = form.WMPlayer;
    WMPLib.IWMPPlaylist mediaPlaylist = Player.mediaCollection.getByAttribute("MediaType", "audio"); //Get the audio medias.
    

    Fill in different parameters in getByAttribte to get what you want.