From 054ff34ddbed3edfde1aec31e3cb6e5281e4c799 Mon Sep 17 00:00:00 2001 From: Zarg <62082797+Zaarrg@users.noreply.github.com> Date: Sun, 26 Jan 2025 20:38:34 +0100 Subject: [PATCH] Blackscreen + Volume Control fix and more fixes - Fixed Blackscreen and volume control being disabled bug. - Fixed Alt+Tab not focusing webview correctly - Added InitalVolume and VO (VideoOutput) to stremio-settings.ini. - Added updater clean up which deletes all old installers. --- src/core/globals.cpp | 3 +++ src/core/globals.h | 3 +++ src/mpv/player.cpp | 3 +++ src/ui/mainwindow.cpp | 12 ++++++++++++ src/updater/updater.cpp | 11 +++++++++++ src/utils/config.cpp | 7 +++++++ utils/stremio/stremio-settings.ini | 3 +++ 7 files changed, 42 insertions(+) diff --git a/src/core/globals.cpp b/src/core/globals.cpp index 8c54d3f..8a091c5 100644 --- a/src/core/globals.cpp +++ b/src/core/globals.cpp @@ -20,6 +20,9 @@ bool g_autoupdaterForceFull = false; // mpv mpv_handle* g_mpv = nullptr; std::set g_observedProps; +bool g_initialSet = false; +std::string g_initialVO = "gpu-next"; +int g_currentVolume = 50; // Node std::atomic_bool g_nodeRunning = false; diff --git a/src/core/globals.h b/src/core/globals.h index f6a396d..887cd07 100644 --- a/src/core/globals.h +++ b/src/core/globals.h @@ -51,6 +51,9 @@ extern bool g_autoupdaterForceFull; // mpv extern mpv_handle* g_mpv; extern std::set g_observedProps; +extern bool g_initialSet; +extern std::string g_initialVO; +extern int g_currentVolume; // custom messages #define WM_MPV_WAKEUP (WM_APP + 2) diff --git a/src/mpv/player.cpp b/src/mpv/player.cpp index 02c7bce..3f55c78 100644 --- a/src/mpv/player.cpp +++ b/src/mpv/player.cpp @@ -131,6 +131,9 @@ void HandleMpvEvents() j["data"]=nullptr; break; } + if (j["name"] == "volume" && g_initialSet) { + g_currentVolume = j["data"]; + } SendToJS("mpv-prop-change", j); break; } diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index abe905b..2846441 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -134,6 +134,11 @@ void HandleEvent(const std::string &ev, std::vector &args) if(ev=="mpv-command"){ if(!args.empty() && args[0] == "loadfile" && args.size() > 1) { args[1] = decodeURIComponent(args[1]); + std::vector voArgs = {"vo",g_initialVO}; + HandleMpvSetProp(voArgs); + std::vector volumeArgs = {"volume", std::to_string(g_currentVolume)}; + HandleMpvSetProp(volumeArgs); + g_initialSet = true; } HandleMpvCommand(args); } else if(ev=="mpv-set-prop"){ @@ -488,6 +493,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if(LOWORD(wParam)==WA_INACTIVE){ pauseMPV(g_pauseOnLostFocus); } + if (LOWORD(wParam) != WA_INACTIVE) + { + SetFocus(hWnd); + if (g_webview && g_webviewController) { + g_webviewController->MoveFocus(COREWEBVIEW2_MOVE_FOCUS_REASON_PROGRAMMATIC); + } + } break; } case WM_SIZE: diff --git a/src/updater/updater.cpp b/src/updater/updater.cpp index 3b6323a..778eb50 100644 --- a/src/updater/updater.cpp +++ b/src/updater/updater.cpp @@ -181,6 +181,17 @@ void RunAutoUpdaterOnce() std::string filename = url.substr(url.find_last_of('/') + 1); std::filesystem::path installerPath = tempDir / std::wstring(filename.begin(), filename.end()); + // Cleanup: Delete all files in tempDir except the current installer + for (const auto& entry : std::filesystem::directory_iterator(tempDir)) { + if (entry.path() != installerPath) { + try { + std::filesystem::remove_all(entry.path()); + } catch (const std::exception& e) { + AppendToCrashLog("[UPDATER]: Cleanup failed for " + entry.path().string() + ": " + e.what()); + } + } + } + if(std::filesystem::exists(installerPath)) { if(FileChecksum(installerPath) != expectedChecksum) { std::filesystem::remove(installerPath); diff --git a/src/utils/config.cpp b/src/utils/config.cpp index 8fe604d..ef8eb80 100644 --- a/src/utils/config.cpp +++ b/src/utils/config.cpp @@ -29,6 +29,13 @@ void LoadSettings() g_allowZoom = GetPrivateProfileIntW(L"General", L"AllowZoom", 0, iniPath.c_str()); g_pauseOnMinimize = (GetPrivateProfileIntW(L"General", L"PauseOnMinimize", 1, iniPath.c_str()) == 1); g_pauseOnLostFocus = (GetPrivateProfileIntW(L"General", L"PauseOnLostFocus", 0, iniPath.c_str()) == 1); + //Mpv + wchar_t voBuffer[32]; + GetPrivateProfileStringW(L"MPV", L"VideoOutput", L"gpu-next", voBuffer, 32, iniPath.c_str()); + char narrowVO[32]; + WideCharToMultiByte(CP_UTF8, 0, voBuffer, -1, narrowVO, 32, NULL, NULL); + g_initialVO = narrowVO; + g_currentVolume = GetPrivateProfileIntW(L"MPV", L"InitialVolume", 50, iniPath.c_str()); } void SaveSettings() diff --git a/utils/stremio/stremio-settings.ini b/utils/stremio/stremio-settings.ini index bc94657..60a9ea6 100644 --- a/utils/stremio/stremio-settings.ini +++ b/utils/stremio/stremio-settings.ini @@ -5,3 +5,6 @@ ThumbFastHeight=0 PauseOnMinimize=1 PauseOnLostFocus=0 AllowZoom=0 +[MPV] +VideoOutput=gpu-next +InitialVolume=50