如何检测现在是否正在播放任何视频? [英] How to detect if any video is being played now?

查看:81
本文介绍了如何检测现在是否正在播放任何视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 , , , ,或 ?

How to detect if any video is being played now using autohotkey, autoit, vbscript, c#, or c?

视频可以在任何本地播放器、基于网络的播放器或 html5 播放器中播放/流式传输.我们不知道播放器的名字,播放器也可能不会全屏显示.

Video could be being played/streamed in any local player, web based player, or html5 player. We do not know the name of player also player may not be in the full screen.

附注.检测 CPU 负载可能不会总是给出正确的结果,所以这是不可接受的.

PS. Detecting CPU load may not give the correct result always, so it is not acceptable.

推荐答案

我以前在这方面做了一些工作.有一个 WIN32API(老派)可以获取/设置是否禁用屏幕保护程序(在 user32.dll、GetScreenSaverActive()、SetScreenSaverActive 中 - 请参阅:http://www.codeproject.com/Articles/17067/Controlling-The-Screen-Saver-With-C).这是播放视频时最有可能设置的标志,但它不是 100% 可靠的,因为不是每个播放器都会实现它.它适用于大多数浏览器视频,无论是通过插件、本地播放还是通过 DirectX 播放.这也适用于大多数(所有?)外部播放器,例如 vlc、windvd 等.

I've done a small bit of work on this back in the day. There is a WIN32API (old school) that gets/sets whether or not to disable the screensaver (in user32.dll, GetScreenSaverActive(), SetScreenSaverActive - see: http://www.codeproject.com/Articles/17067/Controlling-The-Screen-Saver-With-C). This is the most likely flag to be set when a video is playing but it not 100% reliable as not every player will implement it. It WILL work for most browser videos, whether played through plugin, natively, or via DirectX. This also works for most (all?) external players such as vlc, windvd, etc.

但是.

没有确定的 100% 确定视频播放的方法.你不能;1. 检查声音播放,因为用户可能正在使用 iTunes 而并非所有视频都有声音2. 检查全屏(通常是更好的选择),因为视频可能正在浏览器中播放3.检查cpu/gpu负载,因为它不可靠,你没有其他方法来确定4. 绝对确保玩家在最小化时没有清除/重置 win32 标志

There is no sure-fire, 100% way of determining a video playing. You cannot; 1. Check for sound playing as the user may be using iTunes and not all videos have sound 2. Check for full screen (usually the better option) as the video may be playing in a browser 3. Check cpu/gpu load as it's not reliable and you have no other way to determine 4. Be absolutely sure that the player hasn't cleared/reset the win32 flag when minimized

另一种选择是尝试整理所有已知播放器的可能可执行名称列表(可行但查找数据很耗时,尤其是在旧版本上),并检查它们是否正在运行.这也不是 100% 可靠的插件,因为它是预加载的,而是浏览器的,但当时并没有真正播放视频.

Another option would be to try and collate a list of possile executable names for all known players (doable but time consuming to find data, espesially on older versions), and check to see if they're running. This isn't 100% reliable either as a plugin by be preloaded but a browser but not actually playing a video at that moment in time.

简而言之,我知道没有 100% 的方法,但有几种方法可以让您达到 90-95%.这是知道是否有视频播放的目的?也许有一种更简单的方法可以找到您要找的东西...

In short, there's no 100% way that I know of but several ways that'll get you 90-95% there. That is the purpose of knowing if there's a video playing? Perhaps there's an easier way to find what you're looking for...

这篇关于如何检测现在是否正在播放任何视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆