Add automatic update system using GitHub Releases#37
Add automatic update system using GitHub Releases#37arthur-moebios wants to merge 3 commits intoAntonyCorbett:masterfrom
Conversation
This pull request introduces a complete automatic update mechanism for JwlMediaWin. The application now checks for the latest release published on GitHub and, if a newer version is available, offers to download and install it automatically. Key Features Added VersionDetection class to fetch and parse version data from GitHub’s releases/latest API. Implemented UpdateService that: Compares the local assembly version with the remote version. Prompts the user to install updates. Downloads the installer (.exe or .msi) and runs it (with elevation when needed). Logs detailed update information using Serilog. Integrated automatic background check at app startup. Added optional tray menu item “Check for updates…” to trigger the update manually. Implemented robust fallback behavior: Opens the GitHub Releases page if direct download fails. Handles user-canceled UAC prompts and missing assets gracefully. Creates an installer log file for debugging update failures. Technical Notes Compatible with C# 7.3 / .NET Framework 4.8. Uses only standard APIs (no external dependencies). Logs use English messages consistent with the project style. Maintains silent installer support (/VERYSILENT /NORESTART), with logging to %TEMP%/JwlMediaWinSetup.log. New Files Services/UpdateService.cs Services/IUpdateService.cs VersionDetection.cs Modified Files App.xaml.cs: runs update check in background on startup.
|
@arthur-moebios Thank you for your PR - I'll review it asap. |
AntonyCorbett
left a comment
There was a problem hiding this comment.
There are a large number of style warnings associated with changes and additions in the PR. If you can adjust that would be great, but I can do it after merging if needed. Thanks again for your hard work.
JwlMediaWin/App.xaml.cs
Outdated
| using GalaSoft.MvvmLight.Messaging; | ||
| using Hardcodet.Wpf.TaskbarNotification; | ||
| using PubSubMessages; | ||
| using JwlMediaWin.Services; |
JwlMediaWin/App.xaml.cs
Outdated
| } | ||
| catch | ||
| { | ||
| // optional: log here if you have a static logger ready at this time |
There was a problem hiding this comment.
Yes, the logger is configured, so perhaps we can log the error, please.
There was a problem hiding this comment.
Right, i´ve add System.Exception to catch the ex, ok?
| // Se quiser ainda mais verboso: remova /NORESTART para ver prompts de reboot, se houver. | ||
| } | ||
|
|
||
| Process proc = Process.Start(psi); |
There was a problem hiding this comment.
Are we starting the process twice? See also line 142
| if (info.AssetUri == null) | ||
| { | ||
| Log.Warning("[Update] No downloadable asset found. Opening Releases page instead."); | ||
| Process.Start(info.HtmlPage.AbsoluteUri); |
There was a problem hiding this comment.
Use ProcessStartInfo { UseShellExecute = true } to reliably open URLs on .NET Framework.
There was a problem hiding this comment.
Perfect, thanks for information
Sure brother! I’ll do and commit asap thank you! |
|
Summary
✅ Changes
Fallback: cmd /c start "" "" if the primary attempt fails. Logging
Files touched |
There was a problem hiding this comment.
Please would you describe the use of FrameMotionDetector?
There was a problem hiding this comment.
Absolutely, it's a file shouldn't be there. I was developing a detector to call zoom sharing for personal use. But didn't notice was on commit.
FrameMotionDetector is a low-level screen capture and frame-difference analyzer.
It’s used by JwlMediaWin to determine when JW Library changes its visual content — specifically, to detect whether the current media context is an image or a video window.
Because JW Library doesn’t expose an API or event for “media started” or “media stopped”, the app needs a way to observe screen changes directly.
That’s what FrameMotionDetector provides.
⸻
⚙️ How it works
1. Captures the JW Library client area
GetClientRect(hWnd, out RECT rect);
GetDC(hWnd); BitBlt(...);
It uses Win32 APIs (user32.dll + gdi32.dll) to copy the current window pixels into a Bitmap.
2. Compares consecutive frames
• Each captured frame is converted into grayscale or byte array.
• It calculates the difference between the current and the previous frame.
• If the amount of pixel change exceeds a threshold, it flags “motion detected”.
3. Publishes motion events
• The caller (e.g. Fixer or MediaWatcher) uses this to decide:
• No motion → likely a still image (slide or paused video).
• Motion present → likely a playing video.
4. Resource management
• Uses P/Invoke to manage device contexts (GetDC, ReleaseDC).
• Implements IDisposable to ensure cleanup of bitmaps and HDCs.
• Runs on a background thread with short sleeps between frames (e.g., 100–200 ms).
⸻
🧩 Integration in JwlMediaWin
• Fixer or MediaAndCoreWindows creates a FrameMotionDetector instance targeting JW Library’s media window handle (HWND).
• The detector continuously samples frames to identify whether the user started a video.
• Once motion is detected, the app automatically:
• Triggers the Zoom sharing workflow (if automation is enabled).
• Switches internal context from Image → Video.
Example:
using (var detector = new FrameMotionDetector(jwMediaHwnd))
{
detector.Start();
while (true)
{
if (detector.IsMotionDetected)
UpdateContext(MediaContext.Video);
else
UpdateContext(MediaContext.Image);
Thread.Sleep(200);
}
}
Design advantages
• Non-intrusive: doesn’t hook into JW Library’s internals.
• Universal: works regardless of app version or platform changes.
• Lightweight: captures a small region and uses bitmap diffs, not full video processing.
I'll wait for instructions of what do about it, commit again removing the file and references?
There was a problem hiding this comment.
Thanks for the explanation - interesting stuff :) Let's keep it simple here and remove from the PR please.
| <Reference Include="System.Drawing.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> | ||
| <HintPath>..\packages\System.Drawing.Common.10.0.0-rc.1.25451.107\lib\net462\System.Drawing.Common.dll</HintPath> | ||
| </Reference> | ||
| <Reference Include="System.Drawing.Design" /> |
There was a problem hiding this comment.
Can we remove the hints and hence the ref to rc?
JwlMediaWin/App.xaml.cs
Outdated
| } | ||
| finally | ||
| { | ||
| Log.Logger.Information("==== Exit ===="); |
There was a problem hiding this comment.
This log message is misleading. It logs the thread's completion, but "Exit" is what is logged when the app closes.
| </Reference> | ||
| <Reference Include="System.Drawing.Design"> | ||
| <HintPath>..\..\..\..\..\..\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Drawing.Design.dll</HintPath> | ||
| </Reference> |
There was a problem hiding this comment.
I believe we only need System.Drawing
Updates based on comments
|
Commited changes, thanks for attention brother |
Thanks. I've converted the PR to a draft as it doesn't build at the moment. Let me know if you have any questions |
This pull request introduces a complete automatic update mechanism for JwlMediaWin. The application now checks for the latest release published on GitHub and, if a newer version is available, offers to download and install it automatically.
Key Features
Added VersionDetection class to fetch and parse version data from GitHub’s releases/latest API.
Implemented UpdateService that:
Compares the local assembly version with the remote version.
Prompts the user to install updates.
Downloads the installer (.exe or .msi) and runs it (with elevation when needed).
Logs detailed update information using Serilog.
Integrated automatic background check at app startup.
Added optional tray menu item “Check for updates…” to trigger the update manually.
Implemented robust fallback behavior:
Opens the GitHub Releases page if direct download fails.
Handles user-canceled UAC prompts and missing assets gracefully.
Creates an installer log file for debugging update failures.
Technical Notes
Compatible with C# 7.3 / .NET Framework 4.8.
Uses only standard APIs (no external dependencies).
Logs use English messages consistent with the project style.
Maintains silent installer support (/VERYSILENT /NORESTART), with logging to %TEMP%/JwlMediaWinSetup.log.
New Files
Services/UpdateService.cs
Services/IUpdateService.cs
VersionDetection.cs
Modified Files
App.xaml.cs: runs update check in background on startup.