diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/DoubleToHMSConverter.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/DoubleToHMSConverter.cs
new file mode 100644
index 0000000..fd51091
--- /dev/null
+++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/DoubleToHMSConverter.cs
@@ -0,0 +1,43 @@
+using System;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Data;
+
+namespace QuickLook.Plugin.VideoViewer
+{
+ public sealed class DecimalToTimeSpanConverter : DependencyObject, IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value == null)
+ return "00:00:00";
+
+ var time = TimeSpan.FromSeconds((double) (decimal) value);
+
+ return time.ToString(@"hh\:mm\:ss");
+ }
+
+ object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public sealed class DoubleToTimeSpanConverter : DependencyObject, IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value == null)
+ return "00:00:00";
+
+ var time = TimeSpan.FromSeconds((double) value);
+
+ return time.ToString(@"hh\:mm\:ss");
+ }
+
+ object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/HorizontalSliderStyle.xaml b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/HorizontalSliderStyle.xaml
new file mode 100644
index 0000000..2f3152a
--- /dev/null
+++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/HorizontalSliderStyle.xaml
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/PluginInterface.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/PluginInterface.cs
index 097cced..def0646 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/PluginInterface.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/PluginInterface.cs
@@ -34,6 +34,8 @@ namespace QuickLook.Plugin.VideoViewer
using (var element = new MediaElement {Source = new Uri(path)})
{
context.SetPreferredSizeFit(new Size(element.NaturalVideoWidth, element.NaturalVideoHeight), 0.6);
+ context.PreferredSize = new Size(context.PreferredSize.Width,
+ context.PreferredSize.Height + 26); // add control bar
}
}
@@ -45,7 +47,8 @@ namespace QuickLook.Plugin.VideoViewer
_vp.LoadAndPlay(path);
- context.Title = $"{Path.GetFileName(path)} ({TimeSpan.FromSeconds(_vp.mediaElement.NaturalDuration).ToString(@"hh\:mm\:ss")}, {_vp.mediaElement.NaturalVideoWidth} × {_vp.mediaElement.NaturalVideoHeight} )";
+ context.Title =
+ $"{Path.GetFileName(path)} ({_vp.mediaElement.NaturalVideoWidth}×{_vp.mediaElement.NaturalVideoHeight})";
context.IsBusy = false;
}
@@ -54,4 +57,4 @@ namespace QuickLook.Plugin.VideoViewer
_vp?.Dispose();
}
}
-}
+}
\ No newline at end of file
diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Properties/AssemblyInfo.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Properties/AssemblyInfo.cs
index c9740cb..36e5d4e 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Properties/AssemblyInfo.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Properties/AssemblyInfo.cs
@@ -1,6 +1,4 @@
using System.Reflection;
-using System.Resources;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
@@ -31,13 +29,13 @@ using System.Windows;
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
-[assembly:ThemeInfo(
+[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
- //(used if a resource is not found in the page,
- // or application resource dictionaries)
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
- //(used if a resource is not found in the page,
- // app, or any theme specific resource dictionaries)
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
)]
@@ -52,4 +50,4 @@ using System.Windows;
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
\ No newline at end of file
diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Properties/Settings.Designer.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Properties/Settings.Designer.cs
index 56d8efc..a6de71d 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Properties/Settings.Designer.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Properties/Settings.Designer.cs
@@ -8,21 +8,17 @@
//
//------------------------------------------------------------------------------
-namespace QuickLook.Plugin.VideoViewer.Properties
-{
+namespace QuickLook.Plugin.VideoViewer.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
- internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
- {
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.1.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
- public static Settings Default
- {
- get
- {
+ public static Settings Default {
+ get {
return defaultInstance;
}
}
diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Properties/Settings.settings b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Properties/Settings.settings
index 033d7a5..c14891b 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Properties/Settings.settings
+++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/Properties/Settings.settings
@@ -1,4 +1,5 @@
+
diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/QuickLook.Plugin.VideoViewer.csproj b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/QuickLook.Plugin.VideoViewer.csproj
index 393fd2d..ab0e8e1 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/QuickLook.Plugin.VideoViewer.csproj
+++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/QuickLook.Plugin.VideoViewer.csproj
@@ -35,14 +35,12 @@
false
+
+ ..\..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll
+
-
-
-
-
-
4.0
@@ -54,10 +52,15 @@
+
+ MSBuild:Compile
+ Designer
+
MSBuild:Compile
Designer
+
ViewerPanel.xaml
@@ -82,6 +85,7 @@
ResXFileCodeGenerator
Resources.Designer.cs
+
SettingsSingleFileGenerator
Settings.Designer.cs
diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml
index 553d68f..dcb9215 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml
+++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml
@@ -1,15 +1,46 @@
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs
index a52803b..b245c11 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/ViewerPanel.xaml.cs
@@ -1,28 +1,57 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
+using FontAwesome.WPF;
+using Unosquare.FFmpegMediaElement;
namespace QuickLook.Plugin.VideoViewer
{
///
- /// Interaction logic for UserControl1.xaml
+ /// Interaction logic for UserControl1.xaml
///
public partial class ViewerPanel : UserControl, IDisposable
{
public ViewerPanel()
{
InitializeComponent();
+
+ buttonPlayPause.MouseLeftButtonUp += TogglePlayPause;
+
+ mediaElement.PropertyChanged += ChangePlayPauseButton;
+ mediaElement.MouseLeftButtonUp += TogglePlayPause;
+ mediaElement.MediaErrored += ShowErrorOverlay;
+ mediaElement.MediaFailed += ShowErrorOverlay;
+ }
+
+ public void Dispose()
+ {
+ mediaElement?.Dispose();
+ }
+
+ private void TogglePlayPause(object sender, MouseButtonEventArgs e)
+ {
+ if (mediaElement.IsPlaying)
+ mediaElement.Pause();
+ else
+ mediaElement.Play();
+ }
+
+ private void ChangePlayPauseButton(object sender, PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName != "IsPlaying" && e.PropertyName != "HasMediaEnded")
+ return;
+
+ buttonPlayPause.Icon = mediaElement.IsPlaying
+ ? FontAwesomeIcon.PauseCircleOutline
+ : FontAwesomeIcon.PlayCircleOutline;
+ }
+
+ private void ShowErrorOverlay(object sender, MediaErrorRoutedEventArgs e)
+ {
+ mediaElement.Stop();
+ errorOverlay.Visibility = Visibility.Visible;
}
public void LoadAndPlay(string path)
@@ -36,10 +65,5 @@ namespace QuickLook.Plugin.VideoViewer
GC.SuppressFinalize(this);
Dispose();
}
-
- public void Dispose()
- {
- mediaElement?.Dispose();
- }
}
-}
+}
\ No newline at end of file
diff --git a/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/packages.config b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/packages.config
new file mode 100644
index 0000000..069c91c
--- /dev/null
+++ b/QuickLook.Plugin/QuickLook.Plugin.VideoViewer/packages.config
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file