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

@@ -7,24 +7,13 @@ using System.Globalization;
using System.Runtime.InteropServices;
using Peek.Common.Extensions;
using Peek.Common.Models;
using Windows.Foundation;
using Windows.Win32.UI.Shell.PropertiesSystem;
namespace Peek.Common.Helpers
{
public static partial class PropertyStoreHelper
{
/// <summary>
/// Gets a uint type value from PropertyStore from the given item.
/// </summary>
/// <param name="path">The file/folder path</param>
/// <param name="key">The property key</param>
/// <returns>a nullable uint</returns>
public static uint? TryGetUintProperty(string path, PropertyKey key)
{
using DisposablePropertyStore propertyStore = GetPropertyStoreFromPath(path);
return propertyStore.TryGetUInt(key);
}
/// <summary>
/// Gets a ulong type value from PropertyStore from the given item.
/// </summary>
@@ -49,6 +38,28 @@ namespace Peek.Common.Helpers
return propertyStore.TryGetString(key);
}
/// <summary>
/// Gets Size composed of weight (uint) and height (uint) from PropertyStore from the given item.
/// </summary>
/// <param name="path">The file/folder path</param>
/// <param name="widthKey">The property key for width</param>
/// <param name="heightKey">The property key for height</param>
/// <returns>a nullable string</returns>
public static Size? TryGetUintSizeProperty(string path, PropertyKey widthKey, PropertyKey heightKey)
{
Size? size = null;
using DisposablePropertyStore propertyStore = GetPropertyStoreFromPath(path);
uint? width = propertyStore.TryGetUInt(widthKey);
uint? height = propertyStore.TryGetUInt(heightKey);
if (width != null && height != null)
{
size = new Size((float)width, (float)height);
}
return size;
}
/// <summary>
/// Gets a IPropertyStore interface (wrapped in DisposablePropertyStore) from the given path.
/// </summary>
@@ -73,7 +84,7 @@ namespace Peek.Common.Helpers
if (hr != 0)
{
throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "GetPropertyStore returned hresult={0}", hr));
throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "GetPropertyStore returned hresult={0}, errorMessage={1}", hr, Marshal.GetExceptionForHR(hr)!.Message));
}
return new DisposablePropertyStore((IPropertyStore)Marshal.GetObjectForIUnknown(ppPropertyStore));