I want to know the idle time of Mac. Currently I use this code

```
CFMutableDictionaryRef properties = 0;
CFTypeRef obj;
mach_port_t masterPort;
io_iterator_t iter;
io_registry_entry_t curObj;

IOMasterPort(MACH_PORT_NULL, &masterPort);

/* Get IOHIDSystem */
IOServiceGetMatchingServices(masterPort, IOServiceMatching("IOHIDSystem"), &iter);
if (iter == 0)
{
    return -1;
}
else
{
    curObj = IOIteratorNext(iter);
}
if (IORegistryEntryCreateCFProperties(curObj, &properties, kCFAllocatorDefault, 0) == KERN_SUCCESS && properties != NULL)
{
    obj = CFDictionaryGetValue(properties, CFSTR("HIDIdleTime"));
    CFRetain(obj);
}
else
{
    return -1;
}

uint64_t tHandle = 0;
if (obj)
{
    CFTypeID type = CFGetTypeID(obj);

    if (type == CFDataGetTypeID())
    {
        CFDataGetBytes((CFDataRef) obj, CFRangeMake(0, sizeof(tHandle)), (UInt8*) &tHandle);
    }
    else if (type == CFNumberGetTypeID())
    {
        CFNumberGetValue((CFNumberRef)obj, kCFNumberSInt64Type, &tHandle);
    }
    else
    {
        // error
        tHandle = 0;
    }

    CFRelease(obj);

    tHandle /= 1000000; // return as milliseconds
}
else
{
    tHandle = -1;
}

CFRelease((CFTypeRef)properties);
IOObjectRelease(curObj);
IOObjectRelease(iter);
return (double)tHandle;

```

However, I want the idle time to keep 0 if any video is running. 

Is there any code sample or library to check? (include video running on iTunes, VLC, youtube on browser or any other video applications)