Compact Overlay: auto aspect ratio, remember size, auto switch (Issue #278)
3 unresolved threads
Implemented these features (Issue #278):
- Open the compact overlay window with the correct aspect ratio
- Save the size of the compact overlay window, so I don’t have to resize it every time I switch
- Auto toggle to compact overlay when the app window loses focus, so I can switch to another app while I still watching a video very fast
Also, fixed issue #255
Edited by Massimiliano Cristarella
Merge request reports
Activity
Filter activity
- Resolved by Massimiliano Cristarella
- Resolved by Massimiliano Cristarella
- Resolved by Massimiliano Cristarella
347 int currVideoWidth = 16; 348 int currVideoHeight = 9; 349 if (CurrentVideo != null) 350 { 351 currVideoWidth = (int)CurrentVideo.Width; 352 currVideoHeight = (int)CurrentVideo.Height; 353 } 354 355 //Calculate aspect ratio 356 int gcd = GCD(currVideoWidth, currVideoHeight); 357 int ratioWidth = currVideoWidth / gcd; 358 int ratioHeight = currVideoHeight / gcd; 359 360 int expectedHeight = (desideredWidth / ratioWidth) * ratioHeight; 361 362 expectedHeight = expectedHeight < COMPACT_OVERLAY_MIN_HEIGHT ? COMPACT_OVERLAY_MIN_HEIGHT : expectedHeight; Sometimes (depending on the video aspect ratio and the desidered width of the compact overlay window) the expected height is below the minimum supported height or above the maximum supported height, so with lines 362 and 363 I do these checks and then I calculate again the expected width with those limits in mind. I did plenty of tests of this code before so it's all intended behavior.
336 338 { 337 339 PlayerControlVisibilityExtendCurrentRequested?.Invoke(this, EventArgs.Empty); 338 340 } 341 342 public Size CalculateCompactOverlaySize(int desideredWidth) 343 { 344 const int COMPACT_OVERLAY_MIN_HEIGHT = 181; 345 const int COMPACT_OVERLAY_MAX_HEIGHT = 500; 346 347 int currVideoWidth = 16; 348 int currVideoHeight = 9; added 1 commit
- ab60827f - Switched from int to double variables when calculating sizes for more accuracy
236 237 return _autoSwitchToCompactOverlayPiP; 238 } 239 set 240 { 241 SetProperty(ref _autoSwitchToCompactOverlayPiP, value); 242 ApplicationSettingsHelper.SaveSettingsValue(nameof(AutoSwitchToCompactOverlayPiP), value); 243 } 244 } 245 246 public int SavedCompactOverlayPiPWidth 247 { 248 get 249 { 250 var savedWidth = ApplicationSettingsHelper.ReadSettingsValue(nameof(SavedCompactOverlayPiPWidth)); 251 _savedCompactOverlayPiPWidth = (int)(savedWidth ?? 400); changed this line in version 6 of the diff
It's off by default as we discussed in issue #278, now I'm putting that default value in a constant too.