fix: Peek.UI persists as a media player after closed & redundant SMTC…#46899
fix: Peek.UI persists as a media player after closed & redundant SMTC…#46899zheng-fan wants to merge 1 commit intomicrosoft:mainfrom
Conversation
|
@microsoft-github-policy-service agree |
This comment has been minimized.
This comment has been minimized.
daverayment
left a comment
There was a problem hiding this comment.
The FilePreview.xaml.cs changes don't take into account the error fallback case in Previewer_PropertyChanged(). If the last active previewer was an IVideoPreviewer that failed to load, the media transport controls would stay active after the fallback to the default previewer.
A cleaner and more concise fix would be to add an OnPreviewerChanged() partial method (suggested after the existing OnPreviewerChanging()):
partial void OnPreviewerChanged(IPreviewer? value)
{
// Ensure the media transport controls are only present when viewing video media.
VideoPreview.MediaPlayer.CommandManager.IsEnabled = value is IVideoPreviewer;
}This fires for every Previewer = ... assignment - the null path, the normal load path, and the error fallback in Previewer_PropertyChanged(). The IsEnabled lines in OnItemPropertyChanged() can be removed as they're redundant. The longer comment can go, too - the one-liner above is enough to explain why we're controlling IsEnabled here.
(Sorry if this comes across as "please remove all your code and replace it with the above"! Your idea was absolutely correct, it was just that error case that was the problem.)
You were right to make explicit the AudioControl's media transport control behaviour. Great catch!
… control for audio preview
ab8344b to
4e681b3
Compare
|
Thanks for pointing this out! I've revised the code using the method you suggested using Earlier, I added a lot of comments here mainly because I was worried that subsequent developers might be confused: since audio and image files can also be classified as media , why aren't they integrated with SMTC? I'm new to this project, so I'm more than happy to follow your advice! |
… control for audio preview
Summary of the Pull Request
[Peek] Fix #26755 and remove redundant SMTC control for audio preview.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed
Manually verified: When peeking at media and non-media files, navigating between different types of files using the arrow keys, and closing the Peek window, the Hardware Media Key UI all works as expected.