@page "/ffmpeg"
@using ErsatzTV.Application.FFmpegProfiles
@implements IDisposable
@inject IDialogService Dialog
@inject ISnackbar Snackbar
@inject IMediator Mediator
@inject NavigationManager NavigationManager
Add Profile
FFmpeg Profiles
Name
Resolution
Video Format
Audio Format
@context.Name
@context.Resolution.Name
@if (context.HardwareAcceleration != HardwareAccelerationKind.None)
{
@($"{context.VideoFormat.ToString().ToLowerInvariant()} / {context.HardwareAcceleration.ToString().ToLowerInvariant()}")
}
else
{
@context.VideoFormat.ToString().ToLowerInvariant()
}
@context.AudioFormat.ToString().ToLowerInvariant()
@code {
private CancellationTokenSource _cts;
private List _ffmpegProfiles = [];
public void Dispose()
{
_cts?.Cancel();
_cts?.Dispose();
}
protected override async Task OnParametersSetAsync()
{
_cts?.Cancel();
_cts?.Dispose();
_cts = new CancellationTokenSource();
var token = _cts.Token;
try
{
await LoadFFmpegProfilesAsync(token);
}
catch (OperationCanceledException)
{
// do nothing
}
}
private async Task LoadFFmpegProfilesAsync(CancellationToken cancellationToken) =>
_ffmpegProfiles = await Mediator.Send(new GetAllFFmpegProfiles(), cancellationToken);
private async Task DeleteProfileAsync(FFmpegProfileViewModel ffmpegProfile)
{
var parameters = new DialogParameters { { "EntityType", "ffmpeg profile" }, { "EntityName", ffmpegProfile.Name } };
var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall };
IDialogReference dialog = await Dialog.ShowAsync("Delete FFmpeg Profile", parameters, options);
DialogResult result = await dialog.Result;
if (result is { Canceled: false })
{
Either deleteResult = await Mediator.Send(new DeleteFFmpegProfile(ffmpegProfile.Id), _cts.Token);
foreach (BaseError error in deleteResult.LeftToSeq())
{
Snackbar.Add(error.Value, Severity.Error);
}
if (deleteResult.IsRight)
{
await LoadFFmpegProfilesAsync(_cts.Token);
}
}
}
private async Task CopyProfileAsync(FFmpegProfileViewModel ffmpegProfile)
{
var parameters = new DialogParameters { { "FFmpegProfileId", ffmpegProfile.Id } };
var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall };
IDialogReference dialog = await Dialog.ShowAsync("Copy FFmpeg Profile", parameters, options);
DialogResult dialogResult = await dialog.Result;
if (dialogResult is { Canceled: false, Data: FFmpegProfileViewModel data })
{
NavigationManager.NavigateTo($"ffmpeg/{data.Id}");
}
}
}