mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-11 05:52:19 +02:00
[Peek]Use space to play/resume video (#29487)
This commit is contained in:
committed by
GitHub
parent
47aa28977c
commit
4875564a59
@@ -40,6 +40,9 @@
|
|||||||
Source="{x:Bind VideoPreviewer.Preview, Mode=OneWay}"
|
Source="{x:Bind VideoPreviewer.Preview, Mode=OneWay}"
|
||||||
ToolTipService.ToolTip="{x:Bind ImageInfoTooltip, Mode=OneWay}"
|
ToolTipService.ToolTip="{x:Bind ImageInfoTooltip, Mode=OneWay}"
|
||||||
Visibility="{x:Bind IsPreviewVisible(VideoPreviewer, Previewer.State), Mode=OneWay}">
|
Visibility="{x:Bind IsPreviewVisible(VideoPreviewer, Previewer.State), Mode=OneWay}">
|
||||||
|
<MediaPlayerElement.KeyboardAccelerators>
|
||||||
|
<KeyboardAccelerator Key="Space" Invoked="KeyboardAccelerator_Space_Invoked" />
|
||||||
|
</MediaPlayerElement.KeyboardAccelerators>
|
||||||
<MediaPlayerElement.TransportControls>
|
<MediaPlayerElement.TransportControls>
|
||||||
<MediaTransportControls
|
<MediaTransportControls
|
||||||
x:Name="mediaTransport"
|
x:Name="mediaTransport"
|
||||||
|
|||||||
@@ -299,6 +299,28 @@ namespace Peek.FilePreviewer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void KeyboardAccelerator_Space_Invoked(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args)
|
||||||
|
{
|
||||||
|
var mediaPlayer = VideoPreview.MediaPlayer;
|
||||||
|
|
||||||
|
if (mediaPlayer.Source == null || !mediaPlayer.CanPause)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mediaPlayer.CurrentState == Windows.Media.Playback.MediaPlayerState.Playing)
|
||||||
|
{
|
||||||
|
mediaPlayer.Pause();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mediaPlayer.Play();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent the keyboard accelerator to be called twice
|
||||||
|
args.Handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
private async Task UpdateImageTooltipAsync(CancellationToken cancellationToken)
|
private async Task UpdateImageTooltipAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (Item == null)
|
if (Item == null)
|
||||||
|
|||||||
Reference in New Issue
Block a user