From: APTX Date: Sun, 26 Mar 2017 14:06:13 +0000 (+0200) Subject: Quick hack to disable screensaver during playback X-Git-Url: https://gitweb.aptx.org/?a=commitdiff_plain;h=9cf60b4d4ad77b51d48832eabaf6d327a79b737a;p=aniplayer.git Quick hack to disable screensaver during playback Works on windows only, is located in Player. Should be moved to instance manager to correctly account for multiple instances. --- diff --git a/core/player.cpp b/core/player.cpp index 6aa7085..8ff8a1c 100644 --- a/core/player.cpp +++ b/core/player.cpp @@ -3,6 +3,10 @@ #include #include +#ifdef Q_OS_WIN +#include +#endif + Q_LOGGING_CATEGORY(playerCategory, "Player") Player::Player(BackendPluginBase *backendPlugin, QObject *parent) @@ -36,7 +40,12 @@ Player::Player(BackendPluginBase *backendPlugin, QObject *parent) Q_CHECK_PTR(m_chapterModel); } -Player::~Player() { qCDebug(playerCategory) << "Destroying player" << this; } +Player::~Player() { + qCDebug(playerCategory) << "Destroying player" << this; +#ifdef Q_OS_WIN + SetThreadExecutionState(ES_CONTINUOUS); +#endif +} BackendInstance *Player::backend() const { return m_backend; } @@ -199,11 +208,18 @@ void Player::rendererReady() { void Player::playStateChanged(PlayerPluginInterface::PlayState state) { auto s = static_cast(state); - // if (currentSource().isEmpty()) s = PlayState::Stopped; if (m_state == s) return; m_state = s; qCDebug(playerCategory) << "Play state changed to" << s; + +#ifdef Q_OS_WIN + if (m_state == PlayState::Playing) + SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED); + else + SetThreadExecutionState(ES_CONTINUOUS); +#endif + emit stateChanged(s); }