Skip to content

Commit

Permalink
Partially Implemented VideoEntity
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan04 committed Aug 20, 2023
1 parent 7ed6597 commit 89d51f1
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Lagrange.Core/Message/Entity/VideoEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System.Numerics;
using System.Text;
using Lagrange.Core.Core.Packets.Message.Element;
using Lagrange.Core.Core.Packets.Message.Element.Implementation;

namespace Lagrange.Core.Message.Entity;

[MessageElement(typeof(VideoFile))]
public class VideoEntity : IMessageEntity
{
public string FilePath { get; set; } = string.Empty;

public Vector2 Size { get; }

public int VideoSize { get; }

internal VideoEntity(Vector2 size, int videoSize, string filePath)
{
Size = size;
VideoSize = videoSize;
FilePath = filePath;
}

internal VideoEntity() { }

IEnumerable<Elem> IMessageEntity.PackElement()
{
throw new NotImplementedException();
}

IMessageEntity? IMessageEntity.UnpackElement(Elem elem)
{
if (elem.VideoFile is not { } videoFile) return null;

var size = new Vector2(videoFile.FileWidth, videoFile.FileHeight);

return new VideoEntity(size, elem.VideoFile.FileSize, Encoding.UTF8.GetString(elem.VideoFile.FileName));
}

public string ToPreviewString()
{
return $"[Video {Size.X}x{Size.Y}]: {VideoSize}";
}
}

0 comments on commit 89d51f1

Please sign in to comment.