mirror of
https://github.com/QL-Win/QuickLook.git
synced 2026-03-30 01:01:21 +08:00
almost done videoviewer. WIP modify app style to per-window one.
This commit is contained in:
@@ -22,16 +22,22 @@ using System.Windows.Data;
|
||||
|
||||
namespace QuickLook.Plugin.VideoViewer
|
||||
{
|
||||
public sealed class BooleanToVisibilityHiddenConverter : DependencyObject, IValueConverter
|
||||
public sealed class TimeSpanToShortStringConverter : DependencyObject, IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
return Visibility.Collapsed;
|
||||
return "00:00";
|
||||
|
||||
var v = (bool) value;
|
||||
var v = (TimeSpan) value;
|
||||
|
||||
return v ? Visibility.Collapsed : Visibility.Visible;
|
||||
var s = string.Empty;
|
||||
if (v.Hours > 0)
|
||||
s += $"{v.Hours:D2}:";
|
||||
|
||||
s += $"{v.Minutes:D2}:{v.Seconds:D2}";
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -40,7 +40,6 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
};
|
||||
private ContextObject _context;
|
||||
|
||||
private Size _mediaSize = Size.Empty;
|
||||
private ViewerPanel _vp;
|
||||
|
||||
public int Priority => 0 - 10; // make it lower than TextViewer
|
||||
@@ -62,15 +61,25 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
|
||||
var def = new Size(500, 300);
|
||||
|
||||
_mediaSize = GetMediaSizeWithVlc(path);
|
||||
var hasVideo = HasVideoStream(path, out Size mediaSize);
|
||||
|
||||
var windowSize = _mediaSize == Size.Empty ? def : _mediaSize;
|
||||
var windowSize = mediaSize == Size.Empty ? def : mediaSize;
|
||||
windowSize.Width = Math.Max(def.Width, windowSize.Width);
|
||||
windowSize.Height = Math.Max(def.Height, windowSize.Height);
|
||||
|
||||
context.SetPreferredSizeFit(windowSize, 0.6);
|
||||
context.UseDarkTheme = true;
|
||||
context.TitlebarOverlap = true;
|
||||
if (!hasVideo)
|
||||
{
|
||||
context.CanResize = false;
|
||||
context.TitlebarAutoHide = false;
|
||||
context.TitlebarBlurVisibility = false;
|
||||
context.TitlebarColourVisibility = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
context.UseDarkTheme = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void View(string path, ContextObject context)
|
||||
@@ -79,15 +88,11 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
|
||||
context.ViewerContent = _vp;
|
||||
|
||||
|
||||
_vp.mediaElement.VlcMediaPlayer.Opening += MarkReady;
|
||||
|
||||
_vp.LoadAndPlay(path);
|
||||
|
||||
var info = _mediaSize == Size.Empty ? "Audio" : $"{_mediaSize.Width}×{_mediaSize.Height}";
|
||||
|
||||
context.Title =
|
||||
$"{Path.GetFileName(path)} ({info})";
|
||||
context.Title = $"{Path.GetFileName(path)}";
|
||||
}
|
||||
|
||||
public void Cleanup()
|
||||
@@ -105,7 +110,7 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
_context.IsBusy = false;
|
||||
}
|
||||
|
||||
private Size GetMediaSizeWithVlc(string path)
|
||||
private bool HasVideoStream(string path, out Size size)
|
||||
{
|
||||
using (var vlc = new Vlc(VlcSettings.VlcOptions))
|
||||
{
|
||||
@@ -115,7 +120,9 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
var tracks = media.GetTracks();
|
||||
var video = tracks.FirstOrDefault(mt => mt.Type == TrackType.Video) as VideoTrack;
|
||||
|
||||
return video == null ? Size.Empty : new Size(video.Width, video.Height);
|
||||
size = video == null ? Size.Empty : new Size(video.Width, video.Height);
|
||||
|
||||
return video != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
|
||||
@@ -1,61 +1,32 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!-- only for design -->
|
||||
<ResourceDictionary Source="/QuickLook;component/Styles/MainWindowStyles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<Style x:Key="CaptionButtonBaseStyle" TargetType="Button">
|
||||
<Setter Property="Focusable" Value="False" />
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource CaptionButtonIconForeground}" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="CaptionButtonStyle" TargetType="Button" BasedOn="{StaticResource CaptionButtonBaseStyle}">
|
||||
<Style x:Key="ControlButtonStyle" TargetType="Button" BasedOn="{StaticResource CaptionButtonStyle}">
|
||||
<Setter Property="Width" Value="32" />
|
||||
<Setter Property="Height" Value="32" />
|
||||
<Setter Property="Padding" Value="9,9,9,9" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border Background="{TemplateBinding Background}" BorderThickness="0"
|
||||
Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource CaptionButtonHoverBackground}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Background" Value="{DynamicResource CaptionButtonPressBackground}" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<SolidColorBrush x:Key="CustomSliderForegroundBrush" Color="#FFEFEFEF" />
|
||||
<SolidColorBrush x:Key="CustomSliderBackgroundBrush" Color="#EE000000" />
|
||||
<SolidColorBrush x:Key="CustomSliderHighlightBrush" Color="#FFEFEFEF" />
|
||||
|
||||
<!-- Postion Slider Control -->
|
||||
<ControlTemplate x:Key="PositionSliderThumbTemplate" TargetType="{x:Type Thumb}">
|
||||
<Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
|
||||
<Path x:Name="grip" Data="M 0,0 A 180,180 180 1 1 1,1 Z" Fill="Transparent" Stretch="Fill"
|
||||
Stroke="{StaticResource CustomSliderForegroundBrush}" StrokeThickness="1" UseLayoutRounding="True"
|
||||
Stroke="{DynamicResource WindowTextForeground}" StrokeThickness="1" UseLayoutRounding="True"
|
||||
VerticalAlignment="Center"
|
||||
Margin="-1,-1" />
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsDragging" Value="true">
|
||||
<Setter Property="Fill" TargetName="grip" Value="{StaticResource CustomSliderForegroundBrush}" />
|
||||
<Setter Property="Stroke" TargetName="grip" Value="{StaticResource CustomSliderForegroundBrush}" />
|
||||
<Setter Property="Fill" TargetName="grip" Value="{DynamicResource WindowTextForeground}" />
|
||||
<Setter Property="Stroke" TargetName="grip" Value="{DynamicResource WindowTextForeground}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Visibility" TargetName="grip" Value="Hidden" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsKeyboardFocused" Value="true">
|
||||
<Setter Property="Fill" TargetName="grip" Value="{StaticResource CustomSliderForegroundBrush}" />
|
||||
<Setter Property="Fill" TargetName="grip" Value="{DynamicResource WindowTextForeground}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
@@ -68,11 +39,11 @@
|
||||
<DockPanel LastChildFill="True">
|
||||
<Border ClipToBounds="True" x:Name="PART_SelectionRange" Height="1" Visibility="Visible">
|
||||
<Rectangle RadiusX="1" RadiusY="1" Margin="10,0,-10,0"
|
||||
Fill="{StaticResource CustomSliderForegroundBrush}" />
|
||||
Fill="{DynamicResource WindowTextForeground}" />
|
||||
</Border>
|
||||
<Border ClipToBounds="True" Height="1" Visibility="Visible">
|
||||
<Rectangle RadiusX="1" RadiusY="1" Margin="10,0,10,0"
|
||||
Fill="{StaticResource CustomSliderBackgroundBrush}" />
|
||||
Fill="{DynamicResource MainWindowBackground}" />
|
||||
</Border>
|
||||
</DockPanel>
|
||||
<Track x:Name="PART_Track">
|
||||
@@ -106,20 +77,20 @@
|
||||
<!-- Custom Slider Control -->
|
||||
<ControlTemplate x:Key="CustomSliderThumbTemplate" TargetType="{x:Type Thumb}">
|
||||
<Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
|
||||
<Rectangle x:Name="grip" Fill="{StaticResource CustomSliderForegroundBrush}" Width="8"
|
||||
<Rectangle x:Name="grip" Fill="{DynamicResource WindowTextForeground}" Width="8"
|
||||
Height="{Binding Path=Height, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
StrokeThickness="0"
|
||||
UseLayoutRounding="True" Stretch="Fill" RadiusX="3" RadiusY="3" />
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsDragging" Value="true">
|
||||
<Setter Property="Fill" TargetName="grip" Value="{StaticResource CustomSliderHighlightBrush}" />
|
||||
<Setter Property="Fill" TargetName="grip" Value="{DynamicResource WindowTextForeground}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Fill" TargetName="grip" Value="{StaticResource CustomSliderBackgroundBrush}" />
|
||||
<Setter Property="Fill" TargetName="grip" Value="{DynamicResource MainWindowBackground}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsKeyboardFocused" Value="true">
|
||||
<Setter Property="Fill" TargetName="grip" Value="{StaticResource CustomSliderForegroundBrush}" />
|
||||
<Setter Property="Fill" TargetName="grip" Value="{DynamicResource WindowTextForeground}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
@@ -132,11 +103,11 @@
|
||||
<DockPanel LastChildFill="True">
|
||||
<Border ClipToBounds="True" x:Name="PART_SelectionRange" Height="3" Visibility="Visible">
|
||||
<Rectangle RadiusX="1" RadiusY="1" Margin="4,0,-4,0"
|
||||
Fill="{StaticResource CustomSliderForegroundBrush}" />
|
||||
Fill="{DynamicResource WindowTextForeground}" />
|
||||
</Border>
|
||||
<Border ClipToBounds="True" Height="3" Visibility="Visible">
|
||||
<Rectangle x:Name="PART_NegativeSelection" RadiusX="1" RadiusY="1" Margin="8,0,4,0"
|
||||
Fill="{StaticResource CustomSliderBackgroundBrush}" />
|
||||
Fill="{DynamicResource MainWindowBackground}" />
|
||||
</Border>
|
||||
</DockPanel>
|
||||
<Track x:Name="PART_Track">
|
||||
@@ -168,79 +139,4 @@
|
||||
<Setter Property="SelectionEnd" Value="{Binding Path=Value, RelativeSource={RelativeSource Self}}" />
|
||||
<Setter Property="Template" Value="{StaticResource CustomSliderTemplate}" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="NetworkProgressBarStyle" TargetType="{x:Type ProgressBar}">
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Height" Value="3" />
|
||||
<Setter Property="Margin" Value="10,0" />
|
||||
<Setter Property="Minimum" Value="0" />
|
||||
<Setter Property="Maximum" Value="1" />
|
||||
<Setter Property="Background" Value="{StaticResource CustomSliderBackgroundBrush}" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ModernToggleButtonStyle" TargetType="ToggleButton">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#22FFFFFF" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Background" Value="#44FFFFFF" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter Property="Background" Value="#44FFFFFF" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Width" Value="45" />
|
||||
<Setter Property="Height" Value="45" />
|
||||
<Setter Property="Padding" Value="12" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Foreground" Value="{StaticResource CustomSliderHighlightBrush}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ToggleButton}">
|
||||
<Border Background="{TemplateBinding Background}" BorderThickness="0"
|
||||
Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ModernButtonStyle" TargetType="{x:Type Button}">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#22FFFFFF" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Background" Value="#44FFFFFF" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Width" Value="45" />
|
||||
<Setter Property="Height" Value="45" />
|
||||
<Setter Property="Padding" Value="12" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Foreground" Value="{StaticResource CustomSliderHighlightBrush}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border Background="{TemplateBinding Background}" BorderThickness="0"
|
||||
Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ControlsGridStyle" TargetType="{x:Type Grid}">
|
||||
<Setter Property="VerticalAlignment" Value="Bottom" />
|
||||
<Setter Property="Height" Value="250" />
|
||||
<Setter Property="Background" Value="{DynamicResource ShadedBackgroundBrush}" />
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -10,18 +10,19 @@
|
||||
mc:Ignorable="d"
|
||||
x:Name="viewerPanel"
|
||||
d:DesignHeight="300" d:DesignWidth="500">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||
<local:TimeSpanToShortStringConverter x:Key="TimeSpanToShortStringConverter" />
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Styles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.Resources>
|
||||
<ResourceDictionary>
|
||||
<local:BooleanToVisibilityHiddenConverter x:Key="BooleanToVisibilityHiddenConverter" />
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Styles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Grid.Resources>
|
||||
<vlc:VlcPlayer x:Name="mediaElement" LibVlcPath="{Binding LibVlcPath, ElementName=viewerPanel}"
|
||||
VlcOption="{Binding VlcOption, ElementName=viewerPanel}" />
|
||||
<Grid>
|
||||
<Grid x:Name="coverArtPersenter" ClipToBounds="True" Background="{StaticResource MainWindowBackground}">
|
||||
<Grid.Style>
|
||||
<Style TargetType="Grid">
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
@@ -36,25 +37,24 @@
|
||||
<ColumnDefinition Width="4*" />
|
||||
<ColumnDefinition Width="6*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Grid.Column="0" Grid.ColumnSpan="2" ClipToBounds="True">
|
||||
<Rectangle Margin="-50" Grid.Column="0" Grid.ColumnSpan="2">
|
||||
<Rectangle.Effect>
|
||||
<BlurEffect Radius="100"/>
|
||||
<BlurEffect Radius="100" />
|
||||
</Rectangle.Effect>
|
||||
<Rectangle.Fill>
|
||||
<ImageBrush ImageSource="{Binding ElementName=imageCoverArt, Path=Source}" Viewbox="0.15,0,0.7,1" Stretch="UniformToFill" />
|
||||
<ImageBrush ImageSource="{Binding ElementName=imageCoverArt, Path=Source}" Stretch="UniformToFill" Opacity="0.9" />
|
||||
</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"/>
|
||||
<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}"
|
||||
Binding="{Binding CoverArt, ElementName=viewerPanel, FallbackValue=0, TargetNullValue=0}"
|
||||
Value="0">
|
||||
<Setter Property="Source" Value="Resources/compact-disc.png" />
|
||||
</DataTrigger>
|
||||
@@ -62,6 +62,36 @@
|
||||
</Style>
|
||||
</Image.Style>
|
||||
</Image>
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.Effect>
|
||||
<DropShadowEffect ShadowDepth="0" BlurRadius="2" Opacity="0.7" Color="#B2FFFFFF" />
|
||||
</Grid.Effect>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="60" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="10" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock x:Name="metaTitle" Grid.Row="1" FontSize="22" Padding="3"
|
||||
TextWrapping="Wrap"
|
||||
LineHeight="28" MaxHeight="80" TextTrimming="CharacterEllipsis" FontWeight="SemiBold">
|
||||
ときめきポポロン♪
|
||||
</TextBlock>
|
||||
<TextBlock x:Name="metaArtists" Grid.Row="3" FontSize="14" Padding="3" TextTrimming="CharacterEllipsis"
|
||||
Foreground="{DynamicResource WindowTextForeground}">
|
||||
チマメ隊
|
||||
</TextBlock>
|
||||
<TextBlock x:Name="metaAlbum" Grid.Row="4" FontSize="14" Padding="3" TextTrimming="CharacterEllipsis"
|
||||
Foreground="{DynamicResource WindowTextForeground}">
|
||||
ときめきポポロン♪
|
||||
</TextBlock>
|
||||
<TextBlock x:Name="metaLength" Grid.Row="5" FontSize="14" Padding="3" TextTrimming="CharacterEllipsis"
|
||||
Foreground="{DynamicResource WindowTextForeground}"
|
||||
Text="{Binding ElementName=mediaElement, Path=Length, Converter={StaticResource TimeSpanToShortStringConverter}}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="videoControlContainer" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Height="32">
|
||||
@@ -84,9 +114,22 @@
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</Grid.Resources>
|
||||
<glassLayer:GlassLayer BlurredElement="{Binding ElementName=mediaElement}" OverlayColor="#FF3B3B3B" />
|
||||
<glassLayer:GlassLayer OverlayColor="{DynamicResource CaptionBackground}"
|
||||
GlassVisibility="{Binding ElementName=viewerPanel, Path=HasVideo,Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
ColorOverlayVisibility="{Binding ElementName=viewerPanel, Path=HasVideo,Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<glassLayer:GlassLayer.Style>
|
||||
<Style TargetType="glassLayer:GlassLayer">
|
||||
<Setter Property="BlurredElement" Value="{Binding ElementName=viewerPanel}"></Setter>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ElementName=viewerPanel,Path=HasVideo}" Value="True">
|
||||
<Setter Property="BlurredElement" Value="{Binding ElementName=mediaElement}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</glassLayer:GlassLayer.Style>
|
||||
</glassLayer:GlassLayer>
|
||||
<DockPanel>
|
||||
<Button x:Name="buttonPlayPause" Style="{StaticResource CaptionButtonStyle}" DockPanel.Dock="Left">
|
||||
<Button x:Name="buttonPlayPause" Style="{StaticResource ControlButtonStyle}" DockPanel.Dock="Left">
|
||||
<fa:ImageAwesome Foreground="{DynamicResource CaptionButtonIconForeground}">
|
||||
<fa:ImageAwesome.Style>
|
||||
<Style>
|
||||
@@ -101,7 +144,7 @@
|
||||
</fa:ImageAwesome.Style>
|
||||
</fa:ImageAwesome>
|
||||
</Button>
|
||||
<Button x:Name="buttonMute" Style="{StaticResource CaptionButtonStyle}" DockPanel.Dock="Right">
|
||||
<Button x:Name="buttonMute" Style="{StaticResource ControlButtonStyle}" DockPanel.Dock="Right">
|
||||
<fa:ImageAwesome Icon="VolumeUp" Foreground="{DynamicResource CaptionButtonIconForeground}">
|
||||
<fa:ImageAwesome.Style>
|
||||
<Style TargetType="fa:ImageAwesome">
|
||||
@@ -116,10 +159,10 @@
|
||||
</fa:ImageAwesome.Style>
|
||||
</fa:ImageAwesome>
|
||||
</Button>
|
||||
<Button Width="Auto" Style="{StaticResource CaptionButtonStyle}" DockPanel.Dock="Right">
|
||||
<Button Width="Auto" Style="{StaticResource ControlButtonStyle}" DockPanel.Dock="Right">
|
||||
<TextBlock DockPanel.Dock="Right" VerticalAlignment="Center" FontSize="11"
|
||||
Foreground="{DynamicResource CaptionButtonIconForeground}"
|
||||
Text="{Binding Time, StringFormat=hh\\:mm\\:ss, ElementName=mediaElement}"/>
|
||||
Text="{Binding ElementName=mediaElement, Path=Time, Converter={StaticResource TimeSpanToShortStringConverter}}" />
|
||||
</Button>
|
||||
<Slider x:Name="sliderProgress" Style="{StaticResource PositionSliderStyle}"
|
||||
SmallChange="0.00001" LargeChange="0.01" Maximum="1"
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
@@ -26,6 +27,7 @@ using System.Windows.Media.Animation;
|
||||
using Meta.Vlc;
|
||||
using Meta.Vlc.Interop.Media;
|
||||
using QuickLook.Annotations;
|
||||
using QuickLook.ExtensionMethods;
|
||||
using MediaState = Meta.Vlc.Interop.Media.MediaState;
|
||||
|
||||
namespace QuickLook.Plugin.VideoViewer
|
||||
@@ -37,7 +39,7 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
{
|
||||
private readonly ContextObject _context;
|
||||
|
||||
private string _coverArt;
|
||||
private Uri _coverArt;
|
||||
private bool _hasAudio;
|
||||
private bool _hasEnded;
|
||||
private bool _hasVideo;
|
||||
@@ -49,6 +51,9 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// apply global theme
|
||||
Resources.MergedDictionaries[0].MergedDictionaries.Clear();
|
||||
|
||||
ShowViedoControlContainer(null, null);
|
||||
viewerPanel.PreviewMouseMove += ShowViedoControlContainer;
|
||||
|
||||
@@ -145,7 +150,7 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
}
|
||||
}
|
||||
|
||||
public string CoverArt
|
||||
public Uri CoverArt
|
||||
{
|
||||
get => _coverArt;
|
||||
private set
|
||||
@@ -188,6 +193,9 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
|
||||
private void AutoHideViedoControlContainer(object sender, EventArgs e)
|
||||
{
|
||||
if (!HasVideo)
|
||||
return;
|
||||
|
||||
if (videoControlContainer.IsMouseOver)
|
||||
return;
|
||||
|
||||
@@ -220,6 +228,8 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
{
|
||||
var state = e.Value;
|
||||
|
||||
Debug.WriteLine(state);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case MediaState.Opening:
|
||||
@@ -227,8 +237,8 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
HasAudio = mediaElement.VlcMediaPlayer.AudioTrackCount > 0;
|
||||
break;
|
||||
case MediaState.Playing:
|
||||
CoverArt = mediaElement.VlcMediaPlayer.Media.GetMeta(
|
||||
MetaDataType.ArtworkUrl);
|
||||
UpdateMeta();
|
||||
DetermineTheme();
|
||||
HasVideo = mediaElement.VlcMediaPlayer.VideoTrackCount > 0;
|
||||
HasAudio = mediaElement.VlcMediaPlayer.AudioTrackCount > 0;
|
||||
IsPlaying = true;
|
||||
@@ -246,6 +256,37 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateMeta()
|
||||
{
|
||||
if (HasVideo)
|
||||
return;
|
||||
|
||||
var path = mediaElement.VlcMediaPlayer.Media.GetMeta(MetaDataType.ArtworkUrl);
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
CoverArt = new Uri(path);
|
||||
|
||||
metaTitle.Text = mediaElement.VlcMediaPlayer.Media.GetMeta(MetaDataType.Title);
|
||||
metaArtists.Text = mediaElement.VlcMediaPlayer.Media.GetMeta(MetaDataType.Artist);
|
||||
metaAlbum.Text = mediaElement.VlcMediaPlayer.Media.GetMeta(MetaDataType.Album);
|
||||
}
|
||||
|
||||
private void DetermineTheme()
|
||||
{
|
||||
if (HasVideo)
|
||||
return;
|
||||
|
||||
if (CoverArt == null)
|
||||
return;
|
||||
|
||||
var dark = false;
|
||||
using (var bitmap = new Bitmap(CoverArt.LocalPath))
|
||||
{
|
||||
dark = bitmap.IsDarkImage();
|
||||
}
|
||||
|
||||
_context.UseDarkTheme = dark;
|
||||
}
|
||||
|
||||
private void ChangeVolume(double delta)
|
||||
{
|
||||
IsMuted = false;
|
||||
|
||||
Reference in New Issue
Block a user