From 8667853f1821899cdba2dcae040f3f8a0e834fce Mon Sep 17 00:00:00 2001 From: APTX Date: Sat, 16 Aug 2014 12:55:01 +0200 Subject: [PATCH] Prevent windows from turning off the screen when video is playing. --- aniplayer_dshow/aniplayerdshowinternal.cpp | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/aniplayer_dshow/aniplayerdshowinternal.cpp b/aniplayer_dshow/aniplayerdshowinternal.cpp index d0f301e..4c7e27d 100644 --- a/aniplayer_dshow/aniplayerdshowinternal.cpp +++ b/aniplayer_dshow/aniplayerdshowinternal.cpp @@ -57,19 +57,34 @@ AniPlayerDShowInternal::~AniPlayerDShowInternal() bool AniPlayerDShowInternal::play() { HRESULT hr = pControl->Run(); - return SUCCEEDED(hr); + + if (FAILED(hr)) + return false; + + SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED); + return true; } bool AniPlayerDShowInternal::pause() { - HRESULT hr = pControl->Pause(); - return SUCCEEDED(hr); + HRESULT hr = pControl->Pause(); + + if (FAILED(hr)) + return false; + + SetThreadExecutionState(ES_CONTINUOUS); + return true; } bool AniPlayerDShowInternal::stop() { HRESULT hr = pControl->Stop(); - return SUCCEEDED(hr); + + if (FAILED(hr)) + return false; + + SetThreadExecutionState(ES_CONTINUOUS); + return true; } QSize AniPlayerDShowInternal::videoSize() const -- 2.52.0