From 917dd8d52a4a7609754b812583be8d2686bf356e Mon Sep 17 00:00:00 2001 From: Zarg <62082797+Zaarrg@users.noreply.github.com> Date: Wed, 4 Jun 2025 18:13:23 +0200 Subject: [PATCH] Fix Play/Pause media key not working out of focus - Fix media key out of focus not working [86](https://github.com/Zaarrg/stremio-community-v5/issues/86) --- src/main.cpp | 5 +++++ src/ui/mainwindow.cpp | 9 +++++++++ src/utils/crashlog.cpp | 2 ++ 3 files changed, 16 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index d9756d9..ed446ff 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -122,6 +122,11 @@ int main(int argc, char* argv[]) return 1; } + //Add PlayPause Hotkey + if (!RegisterHotKey(g_hWnd, 1, 0, VK_MEDIA_PLAY_PAUSE)) { + AppendToCrashLog(L"[BOOT]: Failed to register hotkey!"); + } + // Scale Values with DPI ScaleWithDPI(); LoadCustomMenuFont(); diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 78efcff..04b63bb 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -391,6 +391,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } break; } + case WM_HOTKEY: + { + // PlayPause Hotkey + if (wParam == 1) { + std::vector args = {"cycle", "pause"}; + HandleMpvCommand(args); + } + break; + } case WM_SETTINGCHANGE: { UpdateTheme(hWnd); diff --git a/src/utils/crashlog.cpp b/src/utils/crashlog.cpp index 83fd9aa..3049de7 100644 --- a/src/utils/crashlog.cpp +++ b/src/utils/crashlog.cpp @@ -67,4 +67,6 @@ void Cleanup() } Discord_Shutdown(); + + UnregisterHotKey(g_hWnd, 1); }