Access the Windows Media Player library C#

2019-03-02 06:21发布

问题:

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

回答1:

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.