-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Persist Peek volume setting across sessions #44050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Persist Peek volume setting across sessions #44050
Conversation
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request implements volume persistence for the Peek utility, allowing users' volume slider adjustments to be saved and restored across sessions. The implementation follows the established pattern used for other user-modifiable settings like ConfirmFileDelete.
Key Changes
- Added
MediaVolumeproperty (0.0-1.0 range) to settings infrastructure with immediate persistence - Implemented bidirectional volume binding from MainWindow through FilePreview to AudioControl and VideoPreview
- Added volume change event propagation with guards to prevent infinite loops
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/settings-ui/Settings.UI.Library/PeekProperties.cs | Added MediaVolume as DoubleProperty with default value of 1.0 (100%) |
| src/modules/peek/Peek.UI/Services/IUserSettings.cs | Added MediaVolume property to interface |
| src/modules/peek/Peek.UI/Services/UserSettings.cs | Implemented MediaVolume getter/setter with clamping and immediate persistence logic |
| src/modules/peek/Peek.UI/MainWindowViewModel.cs | Added MediaVolume property delegating to IUserSettings with proper DI injection |
| src/modules/peek/Peek.UI/PeekXAML/MainWindow.xaml | Added binding and event handler for MediaVolume on FilePreview control |
| src/modules/peek/Peek.UI/PeekXAML/MainWindow.xaml.cs | Added event handler to update ViewModel when volume changes |
| src/modules/peek/Peek.FilePreviewer/FilePreview.xaml | Added MediaVolume binding to AudioControl |
| src/modules/peek/Peek.FilePreviewer/FilePreview.xaml.cs | Added volume change event subscriptions, MediaVolumeProperty, and ApplyMediaVolume logic |
| src/modules/peek/Peek.FilePreviewer/Controls/AudioControl.xaml.cs | Added MediaVolumeProperty, volume change event, and ApplyVolume method with guard flag |
|
|
||
| private void AudioPreview_VolumeChanged(object? sender, double volume) | ||
| { | ||
| MediaVolumeChanged?.Invoke(this, volume); |
Copilot
AI
Dec 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AudioPreview_VolumeChanged handler should check the _isSettingVolume flag before raising the MediaVolumeChanged event, similar to the MediaPlayer_VolumeChanged handler. Without this guard, programmatically setting the volume on the audio player will trigger a volume change event that bubbles up to the ViewModel and saves to settings, potentially causing an infinite loop or unnecessary settings writes.
private void AudioPreview_VolumeChanged(object? sender, double volume)
{
if (!_isSettingVolume)
{
MediaVolumeChanged?.Invoke(this, volume);
}
}| MediaVolumeChanged?.Invoke(this, volume); | |
| if (!_isSettingVolume) | |
| { | |
| MediaVolumeChanged?.Invoke(this, volume); | |
| } |
e51ccd7 to
673d2ed
Compare
This commit implements volume persistence for the Peek utility, so that when users adjust the volume slider for audio/video files, the volume level is remembered and applied to subsequent files. Changes: - Add MediaVolume property to PeekProperties (DoubleProperty, default 1.0) - Add MediaVolume to IUserSettings interface with getter/setter - Implement MediaVolume in UserSettings with save-to-settings logic - Add MediaVolume binding from MainWindow to FilePreview to AudioControl - Add VolumeChanged events in AudioControl and FilePreview - Track user volume changes and bubble up to MainWindowViewModel - Handle volume changes for both audio (AudioControl) and video (MediaPlayerElement) Fixes microsoft#31810
673d2ed to
9393c7e
Compare
Summary of the Pull Request
This PR implements volume persistence for the Peek utility, addressing issue #31810. When users adjust the volume slider for audio or video files in Peek, the volume level is now remembered and applied to subsequent files across sessions.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Implementation Details
The implementation follows the same pattern used for
ConfirmFileDelete- a setting that can be modified directly by Peek and synced back to the settings file.Changes:
Settings Layer (
PeekProperties.cs):MediaVolumeas aDoublePropertywith default value of 1.0 (100%)User Settings (
IUserSettings.cs,UserSettings.cs):MediaVolumeproperty with getter/setterViewModel (
MainWindowViewModel.cs):MediaVolumeproperty that delegates toIUserSettingsIUserSettingsvia DIAudioControl (
AudioControl.xaml.cs):MediaVolumePropertyDependencyPropertyVolumeChangedevent that fires when user changes volume via transport controls_isSettingVolumeflag to prevent recursive updatesFilePreview (
FilePreview.xaml,FilePreview.xaml.cs):MediaVolumePropertyDependencyPropertyMediaVolumeChangedeventApplyMediaVolume()method that sets volume on both video and audio playersVideoPreview.MediaPlayerandAudioPreviewMainWindow (
MainWindow.xaml,MainWindow.xaml.cs):MediaVolumebinding toFilePreviewMediaVolumeChangedevent handler that updates ViewModelHow it works
MediaVolumefrom settingsMainWindowViewModel→FilePreview→AudioControl/VideoPreviewMainWindowViewModelupdatesIUserSettings.MediaVolume, which saves to settings fileValidation Steps Performed