mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-13 11:09:06 +00:00
add seek buttons
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
xmlns:local="clr-namespace:QuickLook.Plugin.VideoViewer"
|
||||
xmlns:ffmpeg="clr-namespace:Unosquare.FFmpegMediaElement;assembly=Unosquare.FFmpegMediaElement"
|
||||
mc:Ignorable="d"
|
||||
Background="#B2454545"
|
||||
d:DesignHeight="449.167" d:DesignWidth="767">
|
||||
<Grid>
|
||||
<Grid.Resources>
|
||||
@@ -94,6 +95,10 @@
|
||||
Visibility="{Binding IsMuted, ElementName=mediaElement, Converter={StaticResource BooleanToVisibilityHiddenConverter}}" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<Grid x:Name="buttonBackward" Style="{StaticResource ControlButtonStyle}">
|
||||
<fa:ImageAwesome Icon="Backward" Height="27" Width="27" Foreground="#FFEFEFEF" />
|
||||
</Grid>
|
||||
<Grid Width="7" />
|
||||
<Grid x:Name="buttonPlayPause" Style="{StaticResource ControlButtonStyle}">
|
||||
<fa:ImageAwesome Height="30" Width="30" Foreground="#FFEFEFEF">
|
||||
<fa:ImageAwesome.Style>
|
||||
@@ -109,10 +114,14 @@
|
||||
</fa:ImageAwesome.Style>
|
||||
</fa:ImageAwesome>
|
||||
</Grid>
|
||||
<Grid Width="15" />
|
||||
<Grid Width="7" />
|
||||
<Grid x:Name="buttonStop" Style="{StaticResource ControlButtonStyle}">
|
||||
<fa:ImageAwesome Icon="Stop" Height="27" Width="27" Foreground="#FFEFEFEF" />
|
||||
</Grid>
|
||||
<Grid Width="7" />
|
||||
<Grid x:Name="buttonForward" Style="{StaticResource ControlButtonStyle}">
|
||||
<fa:ImageAwesome Icon="Forward" Height="27" Width="27" Foreground="#FFEFEFEF" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Orientation="Horizontal" Margin="0,0,20,0">
|
||||
|
@@ -44,6 +44,8 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
//};
|
||||
buttonMute.MouseLeftButtonUp += (sender, e) => mediaElement.IsMuted = !mediaElement.IsMuted;
|
||||
buttonStop.MouseLeftButtonUp += (sender, e) => mediaElement.Stop();
|
||||
buttonBackward.MouseLeftButtonUp += (sender, e) => SeekBackward();
|
||||
buttonForward.MouseLeftButtonUp += (sender, e) => SeekForward();
|
||||
|
||||
mediaElement.MediaErrored += ShowErrorNotification;
|
||||
mediaElement.MediaFailed += ShowErrorNotification;
|
||||
@@ -55,6 +57,24 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
mediaElement = null;
|
||||
}
|
||||
|
||||
private void SeekBackward()
|
||||
{
|
||||
var pos = Convert.ToDouble(mediaElement.Position);
|
||||
var len = mediaElement.NaturalDuration;
|
||||
var delta = TimeSpan.FromSeconds(15).TotalSeconds;
|
||||
|
||||
mediaElement.Position = Convert.ToDecimal(pos - delta < 0 ? 0 : pos - delta);
|
||||
}
|
||||
|
||||
private void SeekForward()
|
||||
{
|
||||
var pos = Convert.ToDouble(mediaElement.Position);
|
||||
var len = mediaElement.NaturalDuration;
|
||||
var delta = TimeSpan.FromSeconds(15).TotalSeconds;
|
||||
|
||||
mediaElement.Position = Convert.ToDecimal(pos + delta > len ? len : pos + delta);
|
||||
}
|
||||
|
||||
private void TogglePlayPause(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (mediaElement.IsPlaying)
|
||||
|
Reference in New Issue
Block a user