wip videoviewer

This commit is contained in:
Paddy Xu
2017-08-08 23:19:46 +03:00
parent 2b3338cc43
commit efaca311fc
10 changed files with 127 additions and 75 deletions

View File

@@ -60,7 +60,7 @@ namespace QuickLook.Plugin.VideoViewer
{
_context = context;
var def = new Size(450, 450);
var def = new Size(500, 300);
_mediaSize = GetMediaSizeWithVlc(path);

View File

@@ -1,9 +1,6 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="CaptionButtonIconForeground" Color="#E5EFEFEF" />
<SolidColorBrush x:Key="CaptionButtonHoverBackground" Color="#22FFFFFF" />
<SolidColorBrush x:Key="CaptionButtonPressBackground" Color="#44FFFFFF" />
<Style x:Key="CaptionButtonBaseStyle" TargetType="Button">
<Setter Property="Focusable" Value="False" />
<Setter Property="Cursor" Value="Hand" />

View File

@@ -9,7 +9,7 @@
xmlns:glassLayer="clr-namespace:QuickLook.Controls.GlassLayer;assembly=QuickLook"
mc:Ignorable="d"
x:Name="viewerPanel"
d:DesignHeight="450" d:DesignWidth="450">
d:DesignHeight="300" d:DesignWidth="500">
<Grid>
<Grid.Resources>
<ResourceDictionary>
@@ -19,31 +19,71 @@
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Grid.Resources>
<vlc:VlcPlayer x:Name="mediaElement" LibVlcPath="{Binding LibVlcPath, ElementName=viewerPanel}"
VlcOption="{Binding VlcOption, ElementName=viewerPanel}" />
<Image>
<Image.Style>
<Style TargetType="Image">
<Setter Property="Source" Value="{Binding CoverArt, ElementName=viewerPanel}" />
<Setter Property="Visibility" Value="Collapsed" />
<Grid>
<Grid.Style>
<Style TargetType="Grid">
<Setter Property="Visibility" Value="Visible" />
<Style.Triggers>
<DataTrigger Binding="{Binding HasVideo, ElementName=viewerPanel}" Value="False">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
<DataTrigger
Binding="{Binding CoverArt.Length, ElementName=viewerPanel, FallbackValue=0, TargetNullValue=0}"
Value="0">
<Setter Property="Source" Value="Resources/compact-disc.png" />
<Setter Property="Margin" Value="50" />
<DataTrigger Binding="{Binding HasVideo, ElementName=viewerPanel}" Value="True">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
</Grid.Style>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="4*" />
<ColumnDefinition Width="6*" />
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Grid.ColumnSpan="2" ClipToBounds="True">
<Rectangle.Effect>
<BlurEffect Radius="100"/>
</Rectangle.Effect>
<Rectangle.Fill>
<ImageBrush ImageSource="{Binding ElementName=imageCoverArt, Path=Source}" Viewbox="0.15,0,0.7,1" Stretch="UniformToFill" />
</Rectangle.Fill>
</Rectangle>
<Image Grid.Column="0" x:Name="imageCoverArt" Margin="20,40,20,40">
<Image.Effect>
<DropShadowEffect Direction="0" BlurRadius="6" Color="#FF898989" ShadowDepth="0"/>
</Image.Effect>
<Image.Style>
<Style TargetType="Image">
<Setter Property="Source" Value="{Binding CoverArt, ElementName=viewerPanel}" />
<Style.Triggers>
<DataTrigger
Binding="{Binding CoverArt.Length, ElementName=viewerPanel, FallbackValue=0, TargetNullValue=0}"
Value="0">
<Setter Property="Source" Value="Resources/compact-disc.png" />
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
</Grid>
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="32">
<Grid x:Name="videoControlContainer" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="32">
<Grid.Resources>
<Storyboard x:Key="ShowControlStoryboard" Completed="AutoHideViedoControlContainer">
<DoubleAnimation
Storyboard.Target="{Binding Source={x:Reference videoControlContainer}}"
Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.05">
</DoubleAnimation>
</Storyboard>
<Storyboard x:Key="HideControlStoryboard">
<DoubleAnimationUsingKeyFrames
Storyboard.Target="{Binding Source={x:Reference videoControlContainer}}"
Storyboard.TargetProperty="Opacity">
<DoubleAnimationUsingKeyFrames.KeyFrames>
<LinearDoubleKeyFrame Value="1" KeyTime="0:0:0" />
<LinearDoubleKeyFrame Value="1" KeyTime="0:0:3" />
<LinearDoubleKeyFrame Value="0" KeyTime="0:0:3.05" />
</DoubleAnimationUsingKeyFrames.KeyFrames>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
<glassLayer:GlassLayer BlurredElement="{Binding ElementName=mediaElement}" OverlayColor="#FF3B3B3B" />
<DockPanel>
<Button x:Name="buttonPlayPause" Style="{StaticResource CaptionButtonStyle}" DockPanel.Dock="Left">

View File

@@ -22,6 +22,7 @@ using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Animation;
using Meta.Vlc;
using Meta.Vlc.Interop.Media;
using QuickLook.Annotations;
@@ -48,6 +49,9 @@ namespace QuickLook.Plugin.VideoViewer
{
InitializeComponent();
ShowViedoControlContainer(null, null);
viewerPanel.PreviewMouseMove += ShowViedoControlContainer;
mediaElement.PropertyChanged += PlayerPropertyChanged;
mediaElement.StateChanged += PlayerStateChanged;
@@ -175,6 +179,23 @@ namespace QuickLook.Plugin.VideoViewer
public event PropertyChangedEventHandler PropertyChanged;
private void ShowViedoControlContainer(object sender, MouseEventArgs e)
{
var show = (Storyboard) videoControlContainer.FindResource("ShowControlStoryboard");
if (videoControlContainer.Opacity == 0 || videoControlContainer.Opacity == 1)
show.Begin();
}
private void AutoHideViedoControlContainer(object sender, EventArgs e)
{
if (videoControlContainer.IsMouseOver)
return;
var hide = (Storyboard) videoControlContainer.FindResource("HideControlStoryboard");
hide.Begin();
}
private void PlayerStop(object sender, MouseButtonEventArgs e)
{
HasEnded = false;