Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the playback rate functionality to use a message-based architecture and standardizes terminology from "speed" to "rate" throughout the codebase. It also extends the maximum playback rate option to 4x and introduces named constants for OEM virtual keys.
Changes:
- Introduces
ChangePlaybackRateRequestMessagefor coordinated playback rate changes via the messenger pattern - Replaces direct property setting with command-based approach using
SetPlaybackRateCommand - Adds named constants (VK_OEM_PLUS, VK_OEM_COMMA, VK_OEM_MINUS, VK_OEM_PERIOD) to replace magic number key codes
- Simplifies playback rate adjustment logic from step-based to linear increment/decrement
- Extends maximum playback rate from 2x to 4x
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Screenbox.Core/Messages/ChangePlaybackRateRequestMessage.cs | New message class for playback rate change requests following the established RequestMessage pattern |
| Screenbox.Core/ViewModels/PlayerControlsViewModel.cs | Renamed PlaybackSpeed to PlaybackRate, added message receiver for rate changes with validation and clamping (0.05-4.0) |
| Screenbox.Core/ViewModels/PlayerPageViewModel.cs | Introduced OEM key constants, refactored rate adjustment to use linear increment/decrement with message-based approach |
| Screenbox/Controls/PlayerControls.xaml | Updated bindings from PlaybackSpeed to PlaybackRate, changed command references, added 4x speed option |
| Screenbox/Controls/PlayerControls.xaml.cs | Updated property and command references to use PlaybackRate terminology |
| Screenbox.Core/Screenbox.Core.csproj | Added new message class to project file |
| [ObservableProperty] private string? _titleName; // TODO: Handle VLC title name | ||
| [ObservableProperty] private string? _chapterName; | ||
| [ObservableProperty] private double _playbackSpeed; | ||
| [ObservableProperty] private double _playbackRate; |
There was a problem hiding this comment.
Field '_playbackRate' can be 'readonly'.
remove unnecessary epsilon comparison reply with the current playback rate
| { | ||
| /// <summary> |
There was a problem hiding this comment.
| { | |
| /// <summary> | |
| { | |
| public const double MinRate = 0.05; | |
| public const double MaxRate = 4.0; | |
| public const double Step = 0.25; | |
| /// <summary> |
Is it a good idea to move the constants to the message?
There was a problem hiding this comment.
I don't think so. These are more of the implementation details. I think they should either be in the view model or a separate static class. Or just not expose these values. I don't think the controls need these values anyway.
There was a problem hiding this comment.
Are you suggesting that the clamping on the message Receive isn't the best approach? I can see that, the controls already handle that. I'd need to apply the clamp on the Shift + ./, shortcut.
There was a problem hiding this comment.
Ah! Clamping it would still be useful, so we can set the minimum on the slider to 0x, making 1x the midpoint.
| case nameof(MediaListViewModel.CurrentItem): | ||
| HasActiveItem = Playlist.CurrentItem != null; | ||
| SubtitleTimingOffset = 0; | ||
| AudioTimingOffset = 0; |
There was a problem hiding this comment.
| AudioTimingOffset = 0; | |
| PlaybackRate = 1.0; |
I wonder if we should reset the playback rate on media change? I don't think so, but maybe behind a setting? Probably not even that.
Adds a new message-based approach for playback rate updates, unifies the terminology from "speed" to "rate", and expands the available playback rate options (4x).
Also adds constants for OEM keys (comma, period, plus, minus).