mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-12-12 02:00:27 +08:00
switch to new FFME control
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
@@ -26,6 +28,7 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
{
|
||||
public class Plugin : IViewer
|
||||
{
|
||||
private Size _mediaSize;
|
||||
private ViewerPanel _vp;
|
||||
|
||||
public int Priority => int.MaxValue;
|
||||
@@ -43,25 +46,28 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
if (Directory.Exists(path))
|
||||
return false;
|
||||
|
||||
var formats = new[]
|
||||
var blacklist = new[]
|
||||
{
|
||||
".3g2", ".3gp", ".3gp2", ".3gpp", ".amv", ".asf", ".asf", ".avi", ".flv", ".m2ts", ".m4v", ".mkv",
|
||||
".mov", ".mp4", ".mp4v", ".mpeg", ".mpg", ".ogv", ".qt", ".vob", ".webm", ".wmv"
|
||||
".txt", ".jpg", ".bmp"
|
||||
};
|
||||
|
||||
if (formats.Contains(Path.GetExtension(path).ToLower()))
|
||||
return true;
|
||||
if (blacklist.Contains(Path.GetExtension(path).ToLower()))
|
||||
return false;
|
||||
|
||||
return false;
|
||||
return new FFprobe(path).CanDecode();
|
||||
}
|
||||
|
||||
public void Prepare(string path, ContextObject context)
|
||||
{
|
||||
var def = new Size(1024, 768);
|
||||
var def = new Size(450, 450);
|
||||
|
||||
var real = new FFprobe(path).GetViewSize();
|
||||
_mediaSize = new FFprobe(path).GetViewSize();
|
||||
|
||||
context.SetPreferredSizeFit(real == Size.Empty ? def : real, 0.6);
|
||||
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);
|
||||
}
|
||||
|
||||
public void View(string path, ContextObject context)
|
||||
@@ -70,11 +76,16 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
|
||||
context.ViewerContent = _vp;
|
||||
|
||||
Debug.WriteLine("ViewerContent done");
|
||||
_vp.LoadAndPlay(path);
|
||||
Debug.WriteLine("LoadAndPlay done");
|
||||
|
||||
_vp.mediaElement.MediaOpened += (sender, e) => context.IsBusy = false;
|
||||
|
||||
var info = _mediaSize == Size.Empty ? "Audio" : $"{_mediaSize.Width}×{_mediaSize.Height}";
|
||||
|
||||
context.Title =
|
||||
$"{Path.GetFileName(path)} ({_vp.mediaElement.NaturalVideoWidth}×{_vp.mediaElement.NaturalVideoHeight})";
|
||||
context.IsBusy = false;
|
||||
$"{Path.GetFileName(path)} ({info})";
|
||||
}
|
||||
|
||||
public void Cleanup()
|
||||
|
||||
Reference in New Issue
Block a user