소스 검색

avalonia: Added EmbeddedVideoControl

Kenric Nugteren 2 달 전
부모
커밋
4fd3600d25
1개의 변경된 파일41개의 추가작업 그리고 0개의 파일을 삭제
  1. 41 0
      PRS.Avalonia/PRS.Avalonia/Components/FormsEditor/Fields/DFEmbeddedVideoFieldControl.cs

+ 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());
+    }
+}