How to use WMPLib in C#

fhulprogrammer picture fhulprogrammer · Mar 18, 2015 · Viewed 26.8k times · Source

I'm trying to import WMPLib but Visual Studio but it's giving message Type or Namespace name 'WMPLib' could not be found. I also tried using System.Windows.Media but again for Media it's giving same message. I tried adding in toolbox Windows Media Player from

Choose Tool Box Items->Com Components->Windows Media Player

But this is not working.

Answer

Gehan Fernando picture Gehan Fernando · Mar 18, 2015

To create the Windows Media Player control programmatically, you must first add a reference to wmp.dll, which is found in the \Windows\system32 folder. Adding this reference creates WMPLib.dll in your project folder, and a reference to WMPLib appears in Solution Explorer.

The following Link will help you.

Creating the Windows Media Player Control Programmatically