Windows Media Player 中当前播放的项目(wmplayer.exe 版本 12)

发布于 2024-09-29 00:44:14 字数 465 浏览 2 评论 0原文

已经尝试这个有一段时间了。 我在网上看到的所有解决方案似乎都不起作用,特别是非常简单的方法。

<代码> WMPLib.WindowsMediaPlayer c = new WMPLib.WindowsMediaPlayer();
IWMPMedia i = (IWMPMedia)c.currentMedia;

c.currentMedia 始终为空。

看来 new WMPLib.WindowsMediaPlayer();始终创建 Windows Media Player 的新实例。 首先,我认为这是我以管理员身份运行 Visual Studio 的事实,但更改这一点并没有帮助。

似乎我必须以某种方式连接到 wmplayer.exe 的运行实例,但无法找到方法来做到这一点。

顺便提一句。我需要的是当前播放歌曲的完整文件 url(如果是流媒体,则为 fullurl,但这是我现在最不关心的问题。)

Been trying this for a while now.
All solutions I've seen on the net don't seem to work, specially the really simple way to do it.


WMPLib.WindowsMediaPlayer c = new WMPLib.WindowsMediaPlayer();
IWMPMedia i = (IWMPMedia)c.currentMedia;

c.currentMedia is always null.

It seems that new WMPLib.WindowsMediaPlayer(); is always creating a new instance of the Windows Media Player.
First I thought it was the fact that I was running visual studio as Administrator, but changing that did not help.

Seems I somehow have to connect to the running instance of wmplayer.exe but have unable to find a way to do that.

Btw. What I need is a full file url for the current playing song (or fullurl if streaming, but that's the least of my concerns now.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静赏你的温柔 2024-10-06 00:44:14

您的问题已在此处得到解答。

  1. 一个非常直接的方法:

    在这里获取一个 WMP9 插件,它将把您当前的歌曲名称放在
    WMP 窗口的标题栏,并使用
    FindWindow P/Invoke 获取窗口
    并获取歌曲名称。它应该有效,
    虽然有点棘手。

    查看此处了解更多详细信息。

    Windows Media Player 9系列博客插件

  2. 更复杂的方式:

    由于您的申请和 WMP 将是不同的流程,因此您的
    场景需要某种
    进程间通信(IPC)。和
    .NET 为此提供了远程处理。

    以下是一些有用的信息:

    如何在 C# 中与 Windows Media Player 交互

    Windows 媒体播放器C# 中的远程处理

来自 SamAgain

Your question answered here.

  1. A pretty straight way:

    Get a WMP9 plugin here that will put your current song name on the
    titlebar of the WMP window, and use
    FindWindow P/Invoke to get the window
    and get the song name. It shoud work,
    though a little tricky.

    Check here for more details.

    Windows Media Player 9 Series Blogging Plug-in

  2. A much more complex way:

    Since your application and the WMP will be different processes, your
    scenario requires some kind of
    inter-process-communication (IPC). And
    .NET offers Remoting for this purpose.

    Below are some useful information:

    How to interact with Windows Media Player in C#

    Windows Media Player Remoting in C#

from SamAgain

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文