How to program to realize the requirement of "real-time monitoring whether the computer sound card makes sound or not"?

event background:
An exe program (designed to hang up for 24 hours to watch video) is written under
. The program has a hypertext browse box embedded to open the specified URL and play the video in the URL. However, occasionally there will be buffering, and sometimes it will be stuck in the buffer interface for a long time, so it needs to be refreshed before it can be played normally.

unsolved requirements:
when is unattended , the program automatically determines whether the video is played normally. If it is on the buffer interface, the program will be refreshed automatically.

scenario:
add a thread to the program to monitor the sound card in real time. If there is no sound for as long as 5 minutes, the video is stuck and does not play properly. So start refreshing the url reload. (this is the only program that runs in the Windows system, and all other audible software is uninstalled. And there is always sound during the normal playback of the video, and there is no sound in the video for 1 minute in a row)

final question:
1. Is this scenario feasible?
2. If this is possible, how can I use C-sharp (or easy language) to detect whether the sound card is producing sound?
3. Is there any other way to monitor whether the video is playing properly in real time? (for example, detecting the pixel change of the progress bar, whether a certain picture area is static for a long time, etc.)

Thank you for your attention!


if the video stutter is caused by the network, it doesn't need to be that complicated.

you can directly monitor the IO traffic of the process. If the video is stuttered, the traffic must be abnormal (small or zero). All you need is an API function GetProcessIoCounters () .

< H2 > reference < / H2 >

GetProcessIoCounters, https://msdn.microsoft.com/en.

< H2 > example < / H2 >
using System;
using System.Threading;
using System.Runtime.InteropServices;


public class Monitor
{
    [StructLayout(LayoutKind.Sequential)]
    public struct IO_COUNTERS {
        public ulong ReadOperationCount;
        public ulong WriteOperationCount;
        public ulong OtherOperationCount;
        public ulong ReadTransferCount;
        public ulong WriteTransferCount;
        public ulong OtherTransferCount;
    }

    [DllImport("kernel32")]
    static extern IntPtr GetCurrentProcess();

    [DllImport("kernel32")]
    static extern bool GetProcessIoCounters(IntPtr process, ref IO_COUNTERS pCounters);

    public static void MonitorCounters()
    {
        IO_COUNTERS pCounters = new IO_COUNTERS();
        while (GetProcessIoCounters(GetCurrentProcess(), ref pCounters)) {
            Console.WriteLine(String.Format("READ: %d, WRITE: %d", pCounters.ReadTransferCount, pCounters.WriteTransferCount));
            Thread.Sleep(1);
        }
    }
}


public class Program
{
    public static void Main()
    {
        Monitor.MonitorCounters();
    }
}
< hr >

to put it beside the point, I recommend that you learn python, which is easy to learn and powerful.


take a closer look at the distance

to be direct, the WebBrowser object is used at the bottom of the hypertext browsing box of easy language, and you can use the hypertext browsing box n. Take the browser object () to get IWebBrowser2 object , and perform related web page level operations.
exactly how to do this depends on the structure of the web page.

C-sharp is also a WebBrowser object, but it seems to be encapsulated in a layer, so you can also refer to the above ideas.


www.autohotkey.com


change the way of thinking. Screenshots are relatively easier to achieve

.
Menu