Learn.VideoAnalysis/VideoAnalysis/Components/Pages/VideoTaskShow.razor.cs

73 lines
2.5 KiB
C#

using AntDesign;
using AntDesign.TableModels;
using FFmpeg.NET.Services;
using Learn.VideoAnalysis.Controllers.Dto;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.DataProtection.KeyManagement;
using SqlSugar;
using System.Linq.Expressions;
using System.Threading.Tasks;
using VideoAnalysisCore.AICore.GPT.Dto;
using VideoAnalysisCore.AICore.SherpaOnnx;
using VideoAnalysisCore.Common;
using VideoAnalysisCore.Enum;
using VideoAnalysisCore.Model;
using VideoAnalysisCore.Model.Dto;
namespace Learn.VideoAnalysis.Components.Pages
{
public partial class VideoTaskShow : ComponentBase
{
[Inject] private ConfirmService ComfirmService { get; set; } = default!;
[Inject] private IHttpContextAccessor HttpContext { get; set; } = default!;
[Inject] private Repository<VideoTask> taskDB { get; set; } = default!;
private VideoTask nowTask { get; set; } = default!;
private string videoPath { get; set; } = default!;
/// <summary>
/// 字幕
/// </summary>
private SenseVoiceRes[] captionsArr { get; set; } = default!;
/// <summary>
/// 分段
/// </summary>
private VideoKnowRes[] videoKnows { get; set; } = default!;
/// <summary>
/// 在渲染页面之后
/// </summary>
/// <param name="firstRender"></param>
/// <returns></returns>
protected override async Task OnAfterRenderAsync(bool firstRender)
{
}
/// <summary>
/// 初始化
/// </summary>
protected override async void OnInitialized()
{
var routeData = HttpContext.HttpContext.GetRouteData();
if (routeData is null)
return;
long taskId = (long)routeData.Values["id"];
nowTask = await taskDB.GetFirstAsync(s => s.Id == taskId);
if(nowTask is null)
return;
captionsArr = RedisExpand.Redis.HMGet<SenseVoiceRes[]>(RedisExpandKey.Task(taskId), "Captions").FirstOrDefault();
videoKnows = RedisExpand.Redis.HMGet<VideoKnowRes[]>(RedisExpandKey.Task(taskId), "VideoKnows").FirstOrDefault();
videoPath = AppCommon.GetVideoPath(nowTask.Id.ToString());
}
private async Task<bool> Comfirm(string message)
{
return await ComfirmService.Show(message, "提示", ConfirmButtons.YesNo, ConfirmIcon.Warning) == ConfirmResult.Yes;
}
}
}