如何在 C# 中使用 WMPLib

fhu*_*mer 3 c# wmplib

我正在尝试导入 WMPLib 但 Visual Studio 但它给出了消息 Type or Namespace name 'WMPLib' could not be found。我也尝试使用 System.Windows.Media 但对于 Media 它再次给出相同的消息。我尝试从工具箱中添加 Windows Media Player

Choose Tool Box Items->Com Components->Windows Media Player
Run Code Online (Sandbox Code Playgroud)

但这是行不通的。

小智 6

要以编程方式创建 Windows Media Player 控件,您必须首先添加对 wmp.dll 的引用,该文件位于 \Windows\system32 文件夹中。添加此引用会在您的项目文件夹中创建 WMPLib.dll,并且对 WMPLib 的引用会出现在解决方案资源管理器中。

以下链接将为您提供帮助。

以编程方式创建 Windows Media Player 控件