从 C# 远程控制 VLC

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/785829/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 01:04:43  来源:igfitidea点击:

VLC remotely control from C#

c#controlsvlc

提问by Sorin Antohi

i'm trying to control the VLC Media Player from C#. I tried getting a handle on the window with the FindWindow() command from .Net but as i found out the name of the window changes every time a file is played. The biggest problem i have is sending wm_commands to vlc..This approach worked with Winamp and Windows Media Player but with VLC it appears that it won't work.

我正在尝试从 C# 控制 VLC 媒体播放器。我尝试使用来自 .Net 的 FindWindow() 命令获取窗口句柄,但我发现每次播放文件时窗口的名称都会更改。我遇到的最大问题是将 wm_commands 发送到 vlc..这种方适用于 Winamp 和 Windows Media Player,但使用 VLC 似乎不起作用。

I read that VLC can be controlled from a browser but i don't whant that...i've seen in it's settings that it has some hot keys that can be called..but they can be changed and if i call them from my code somehow...and the user changes them..bummer...

我读到 VLC 可以从浏览器控制,但我不想要……我在它的设置中看到它有一些可以调用的热键……但是它们可以更改,如果我从我的代码不知何故......用户更改了它们......无赖......

i'm a little bit stuck..any help would be fantastic... Sorin

我有点卡住了......任何帮助都会很棒......索林

采纳答案by Sam Saffron

I have some code that is able to control it using socketson the RC interface. This worked to a degree but has a lot of quirks. go to full screen seems to do nothing for a few seconds after play is invoked. Overall it sort of works.

我有一些代码可以使用RC 接口上的套接字控制它。这在一定程度上有效,但有很多怪癖。在调用播放后的几秒钟内,转到全屏似乎什么都不做。总的来说它有点工作。

The other options are:

其他选项是:

Write a DirectDraw filter (very hard) but once this is done VLC can be used instead of or in conjunction with FFMPEG. Existing code that drives media player could use vlc.

编写一个 DirectDraw 过滤器(非常困难),但一旦完成,VLC 可以代替 FFMPEG 使用或与 FFMPEG 结合使用。驱动媒体播放器的现有代码可以使用 vlc。

Write an interop wrapper for libvlc, recently the VLC team split out libvlccorefrom libvlcso to the best of my knowledge all the interopis out of date. Once you write a wrapper you could embed vlc in a windows app. (if you need to support x64 you need to compile these libs under x64.

libvlc编写一个互操作包装器,最近 VLC 团队libvlccore从中分离出来libvlc,据我所知,所有互操作都过时了。一旦你编写了一个包装器,你就可以将 vlc 嵌入到 Windows 应用程序中。(如果您需要支持 x64,则需要在 x64 下编译这些库。

Look through the VLC code and find out if there is a way to send these windows messages.

查看 VLC 代码,看看是否有办发送这些 Windows 消息。

EDITThis appearsto have come out this week.

编辑这似乎是本周出现的。

回答by Eoin Campbell

Have you looked at libvlc

你看过libvlc

You might be able to wrap that up in a library and interact with VLC through that.

您也许可以将其封装在一个库中并通过它与 VLC 进行交互。

回答by Tormod Fjeldsk?r

As Eoin mentioned, libvlccan be used to interact with VLC. As a C# user, you may want to try the .NET bindings offered by the libvlc-sharpproject.

正如 Eoin 所提到的,libvlc可用于与 VLC 交互。作为 C# 用户,您可能想尝试该libvlc-sharp项目提供的 .NET 绑定。

Edit:Seems like this project has not been maintained for years. I will leave the link anyway, in case you wish to take a look at it and maybe put some of its source to use.

编辑:似乎这个项目已经多年没有维护了。无论如何,我都会留下链接,以防你想看一看它,也许可以使用它的一些来源。

回答by Mark

There's also the rcinterface and even a telnet one: http://wiki.videolan.org/Console

还有rc界面,甚至还有一个 telnet 界面:http: //wiki.videolan.org/Console

However, I'd prefer libvlc if possible.

但是,如果可能,我更喜欢 libvlc。

回答by Erich Mirabal

If what you are trying to do is control a previously running executable, check out the Processclass to enumerate through all the current processesor do it by name. Check the executable to match vlc.exe. You can then get a handle to the main window and do some P/Invoke to send messages as you are doing with your other executables. This is obviously riddled with potential problems such as if the there are changes to the keyboard shotcuts.

如果您想要做的是控制以前运行的可执行文件,请查看Process类以枚举所有当前进程或按名称执行。检查可执行文件以匹配vlc.exe. 然后,您可以获得主窗口的句柄,并像处理其他可执行文件一样执行一些 P/Invoke 来发送消息。这显然充满了潜在的问题,例如键盘快捷键是否有变化。

回答by Erich Mirabal

How use libvlc in C++ http://unick-soft.ru/art/files/libvlcProject.zipI think, use libvlc in C# very similar.

如何在 C++ 中使用 libvlc http://unick-soft.ru/art/files/libvlcProject.zip我认为,在 C# 中使用 libvlc 非常相似。