简体   繁体   中英

Is it possible to programmatically determine if a video is playing?

Is it possible (Preferably with .NET) to determine if a video is currently playing? Even if it's limited to hardware accelerated playback, that would be better than nothing.

Bonus points if I can determine what display in a multi-monitor system it's playing on.

Investigate DirectShowSpy from alax.info. This will allow you to "spy" on running DirectShow graphs. Very useful in conjunction with a tool like GraphStudio .

I'm a C++ developer writing DirectShow apps, and use both tools all the time, they're indispensable debug tools.

Google the subject of the Running Object Table. DirectShow graphs are (normally) added to the Running Object Table, so you can enumerate the ROT in order to determine what graphs are running on the system.

Your video card will employ a DirectShow renderer filter to playback video within a Directshow graph. The renderer is normally fed by a decoder filter. The decoder filter does the job of decoding video and it is the decoder which must be instructed to use DXVA acceleration.

So for example, you might have an H.264 decoder filter in a playback graph, you must instruct it to use DXVA acceleration.

It has been my experience that the decoder filter will have an option to allow you to turn on / off DXVA accelerated video decoding, but this will be specific to the decoder in question, and therefore it'll be much more difficult to universally detect.

So for example, you might write code to detect if DXVA is enabled by querying the decoder filter in a running graph that's decoding an H.264 stream, but code to query the decoder filter for a VP8 graph will most likely have different code.

This MSDN link supports my experience that DXVA acceleration is toggled through the decoder filter; there may be some way to query a graphics card, but I think this would be gfx card vendor specific.

Sorry the answers weren't more specific, but I hope it points you in the right direction...

I don't think it's globally possible as video can be played over DirectX, OpenGL or even GDI. I think your best option is to have a white list of applications that are used for playback and poll on running processes. Once you have the process, you can try and find it's windows/controls and maybe try to get the HDC and use the appropriate(DirectShow most probably) API to query or manipulate the device.

When you have a window a simple call to System.Windows.Forms.Screen will tell you what screen is showing these coordinates.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM