-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.cs
More file actions
68 lines (54 loc) · 1.82 KB
/
Plugin.cs
File metadata and controls
68 lines (54 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using QuickLook.Common.Plugin;
using System;
using System.IO;
using System.Windows;
using System.Windows.Controls;
namespace QuickLook.Plugin.VideoMPF
{
public class Plugin : IViewer
{
//private MediaElement _vpf;
private ViewerPanel _vpf;
public int Priority => int.MaxValue;
public void Init()
{
}
public bool CanHandle(string path)
{
return !Directory.Exists(path) && path.ToLower().EndsWith(".mp4");
}
public void Prepare(string path, ContextObject context) {
int width = 500;
int height = 300;
var windowSize = new Size {
Width = Math.Max(100, width == 0 ? 1366 : width),
Height = Math.Max(100, height == 0 ? 768 : height)
};
context.SetPreferredSizeFit(windowSize, 0.8);
context.TitlebarAutoHide = true;
context.Theme = Themes.Dark;
context.TitlebarBlurVisibility = true;
context.TitlebarOverlap = true;
}
public void View(string path, ContextObject context)
{
//var viewer = new Label {Content = "I am a Label. I do nothing at all."};
//context.ViewerContent = viewer;
//_vpf = new MediaElement();
//_vpf.Source = new Uri(Path.GetFileName(path));
//context.ViewerContent = _vpf;
//_vpf.Play();
//context.IsBusy = false;
_vpf = new ViewerPanel(context, path);
context.ViewerContent = _vpf;
context.Title = $"{Path.GetFileName(path)}";
_vpf.PlaySong();
}
public void Cleanup()
{
_vpf?.Dispose(true);
//_vpf?.Close();
_vpf = null;
}
}
}