Yizzho/peek/videos (#25983)

* Add basics of VideoPreviewer to build on

* WIP

* Minimal working code, todo next:dimension + MTC

* Nits

* Change back to GetImageSize as it indeed doesn't work with videos

* Add win32 helper methods to get video size; Refactor get size operation;

* Remove unused code

* Set VideoTask; Add message error for HR result;

* Add open read only for filestream

* Remove unused code

* Update expect.txt

* Remove comment

* Cleanup code

* Force pause videopreview on previewer change

---------

Co-authored-by: Jojo Zhou <yizzho@microsoft.com>
Co-authored-by: Yawen Hou <yawenhou@microsoft.com>
Co-authored-by: Clint Rutkas <clint@rutkas.com>
Co-authored-by: Yawen Hou <Sytta@users.noreply.github.com>
Co-authored-by: Samuel Chapleau 🌈 <sachaple@microsoft.com>
This commit is contained in:
Jojo Zhou
2023-05-15 14:06:08 -07:00
committed by GitHub
parent 5aa58bf922
commit a0b9af039d
15 changed files with 222 additions and 32 deletions

View File

@@ -33,5 +33,29 @@ namespace Peek.Common.Extensions
return tcs.Task;
}
/// <summary>
/// Run work on UI thread safely.
/// </summary>
/// <returns>True if the work was run successfully, False otherwise.</returns>
public static Task RunOnUiThread(this DispatcherQueue dispatcher, Action work)
{
var tcs = new TaskCompletionSource();
dispatcher.TryEnqueue(() =>
{
try
{
work();
tcs.SetResult();
}
catch (Exception e)
{
tcs.SetException(e);
}
});
return tcs.Task;
}
}
}

View File

@@ -8,6 +8,7 @@ using System.IO;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml;
using Peek.Common.Helpers;
using Peek.Common.Models;
using Scripting;
using Windows.Foundation;
@@ -19,17 +20,12 @@ namespace Peek.Common.Extensions
{
public static Size? GetImageSize(this IFileSystemItem item)
{
Size? size = null;
return PropertyStoreHelper.TryGetUintSizeProperty(item.Path, PropertyKey.ImageHorizontalSize, PropertyKey.ImageVerticalSize);
}
var width = item.Width;
var height = item.Height;
if (width != null && height != null)
{
size = new Size((int)width, (int)height);
}
return size;
public static Size? GetVideoSize(this IFileSystemItem item)
{
return PropertyStoreHelper.TryGetUintSizeProperty(item.Path, PropertyKey.FrameWidth, PropertyKey.FrameHeight);
}
public static Size? GetSvgSize(this IFileSystemItem item)