123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace InABox.Core
- {
- public class DFLayoutVideoFieldProperties : DFLayoutFieldProperties<DFLayoutEmbeddedMediaValue>
- {
- public enum VideoQuality
- {
- Default,
- Low,
- Medium,
- High
- }
-
- [CheckBoxEditor]
- [EditorSequence(100)]
- public bool DisableLibrary { get; set; }
-
- [IntegerEditor(ToolTip = "Maximum video length (sec)")]
- [EditorSequence(101)]
- public int MaximumVideoLength { get; set; } = 0;
- [EnumLookupEditor(typeof(VideoQuality))]
- [EditorSequence(102)]
- public VideoQuality Quality { get; set; } = VideoQuality.Default;
- public override string FormatValue(object? value)
- {
- return value != null ? "Yes" : "";
- }
- public override object? ParseValue(object? value)
- {
- if (value is byte[])
- return value;
- if (value is string str)
- {
- if (Guid.TryParse(str, out var id))
- {
- return Array.Empty<byte>();
- }
- try
- {
- return Convert.FromBase64String(str);
- }
- catch (Exception e)
- {
- Logger.Send(LogType.Error, "", $"Error in video data; invalid Base-64: {e.Message}");
- return null;
- }
- }
- return null;
- }
-
- protected override void LoadProperties()
- {
- base.LoadProperties();
- DisableLibrary = GetProperty(nameof(DisableLibrary), false);
- MaximumVideoLength = GetProperty(nameof(MaximumVideoLength), 0);
- Quality = GetProperty(nameof(Quality), VideoQuality.Default);
- }
- protected override void SaveProperties()
- {
- base.SaveProperties();
- SetProperty(nameof(DisableLibrary), DisableLibrary);
- SetProperty(nameof(MaximumVideoLength),MaximumVideoLength);
- SetProperty(nameof(Quality), Quality);
- }
-
- }
- }
|