ソースを参照

avalonia: Added EmbeddedVideoControl

Kenric Nugteren 2 週間 前
コミット
4fd3600d25

+ 41 - 0
PRS.Avalonia/PRS.Avalonia/Components/FormsEditor/Fields/DFEmbeddedVideoFieldControl.cs

@@ -0,0 +1,41 @@
+using Avalonia.Controls;
+using Avalonia.Media;
+using InABox.Avalonia;
+using InABox.Avalonia.Platform;
+using InABox.Core;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PRS.Avalonia.DigitalForms;
+
+class DFEmbeddedVideoFieldControl : DFEmbeddedMediaFieldControl<DFLayoutVideoField, DFLayoutVideoFieldProperties, byte[]>
+{
+    protected override bool DisableLibrary => Field.Properties.DisableLibrary;
+
+    protected override bool IsVideo => true;
+
+    public override byte[] GetValue() => _value.Data ?? [];
+
+    public override void SetValue(byte[] value)
+    {
+        SetSerializedValue(new() { Data = value });
+    }
+
+    protected override Task<MobileDocument> CaptureMedia()
+    {
+        return MobileDocument.From(App.TopLevel, new MobileDocumentVideoOptions());
+    }
+
+    protected override byte[] CreateThumbnail(byte[] data, int maxWidth = 256, int maxHeight = 256)
+    {
+        return PlatformTools.ImageTools.CreateVideoThumbnail(data, maxWidth, maxHeight);
+    }
+
+    protected override Task<MobileDocument> SelectMedia()
+    {
+        return MobileDocument.From(App.TopLevel, new MobileDocumentVideoLibraryOptions());
+    }
+}