go back to FFME. There is still a memory leak for cover arts.

This commit is contained in:
Paddy Xu
2017-10-16 00:40:01 +03:00
parent 95995eab0e
commit 61d4f7d2c2
19 changed files with 13277 additions and 4605 deletions

View File

@@ -22,6 +22,34 @@ using System.Windows.Data;
namespace QuickLook.Plugin.VideoViewer
{
public sealed class TimeSpanToSecondsConverter : DependencyObject, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is TimeSpan span)
return span.TotalSeconds;
if (value is Duration duration)
return duration.HasTimeSpan ? duration.TimeSpan.TotalSeconds : 0d;
return 0d;
}
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
var span = TimeSpan.Zero;
if (value != null)
span = TimeSpan.FromSeconds((double) value);
if (targetType == typeof(TimeSpan))
return span;
if (targetType == typeof(Duration))
return new Duration(span);
return Activator.CreateInstance(targetType);
}
}
public sealed class TimeSpanToShortStringConverter : DependencyObject, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@@ -29,13 +57,17 @@ namespace QuickLook.Plugin.VideoViewer
if (value == null)
return "00:00";
var v = (TimeSpan) value;
var span = TimeSpan.Zero;
if (value is Duration duration)
span = duration.HasTimeSpan ? duration.TimeSpan : TimeSpan.Zero;
if (value is TimeSpan timespan)
span = timespan;
var s = string.Empty;
if (v.Hours > 0)
s += $"{v.Hours:D2}:";
if (span.Hours > 0)
s += $"{span.Hours:D2}:";
s += $"{v.Minutes:D2}:{v.Seconds:D2}";
s += $"{span.Minutes:D2}:{span.Seconds:D2}";
return s;
}
@@ -55,13 +87,9 @@ namespace QuickLook.Plugin.VideoViewer
if (value == null)
return Volumes[0];
var v = (int) value;
if (v == 0)
return Volumes[0];
var v = (int) Math.Min(100, Math.Max((double) value * 100, 0));
v = Math.Min(v, 100);
return Volumes[1 + v / 34];
return v == 0 ? Volumes[0] : Volumes[1 + v / 34];
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)