A friend has asked me: When I play back audio on my Surface Pro, it stops after a few songs. This is the energy configuration which puts the device in sleep mode after a few minutes on battery. We don't want to change that, but he does want the music to keep on playing, which is totally understandable. I would want the same.
So I've been reading a bit about that. Keeping the device active is only possible with video, not audio, but it wouldn't apply anyway because it also keeps the screen on which isn't needed for audio and only drains the battery faster. Windows' presentation mode does the same, and it complicated to toggle. (He's not very computer-experienced and needs very simple solutions.)
I thought it would be a good solution to change Windows energy settings while VLC is playing audio. It can be done with a simple call to powercfg.exe. I'm already using that for other purposes through the Windows task scheduler. But How do I know when VLC is playing audio? Good ol' WinAmp could be queried by WM messages and the SendMessage function. Does something similar exist for VLC?
Then I found that VLC can host extensions of some sort. I never used this but would it be possible to install an extension that would call powercfg.exe for me when audio playback starts or stops? Where should I start reading about how to use that?
Are there any other ideas about this kind of VLC automation? How do you handle this issue?
Wait, now that I've searched again, I believe VLC could also handle this itself properly. Do the VLC developers know the [url=https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-setthreadexecutionstate]SetThreadExecutionState[/url] function? It doesn't just allow the process to keep the display on (which I thought), it can also prevent standby but allow display idle. That sounds like the proper solution to the requirement. But it would either need to be integrated into VLC, or be used through some other VLC API means, as asked above.