2026-07-13 19:59:40 +00:00
|
|
|
using AIStudio.Tools.Services;
|
2026-07-14 12:41:13 +00:00
|
|
|
using Microsoft.AspNetCore.Components;
|
2026-07-13 19:59:40 +00:00
|
|
|
|
|
|
|
|
namespace AIStudio.Components;
|
|
|
|
|
|
|
|
|
|
public partial class MediaTranscriptionStatus
|
|
|
|
|
{
|
2026-07-14 12:41:13 +00:00
|
|
|
/// <summary>The surface owner whose operation is rendered.</summary>
|
|
|
|
|
[Parameter]
|
|
|
|
|
public MediaImportOwner Owner { get; set; }
|
|
|
|
|
|
|
|
|
|
private MediaImportSnapshot? Snapshot => this.MediaTranscriptionService.GetSnapshot(this.Owner);
|
|
|
|
|
|
2026-07-14 07:00:30 +00:00
|
|
|
/// <summary>Gets the localized visible status for the active import.</summary>
|
2026-07-14 12:41:13 +00:00
|
|
|
private string StatusText => this.Snapshot?.Phase switch
|
2026-07-13 19:59:40 +00:00
|
|
|
{
|
2026-07-14 12:41:13 +00:00
|
|
|
MediaTranscriptionPhase.QUEUED => $"{this.T("Waiting to prepare media")}: {this.Snapshot.CurrentFileName}",
|
|
|
|
|
MediaTranscriptionPhase.PROBING => $"{this.T("Inspecting media")}: {this.Snapshot.CurrentFileName}",
|
|
|
|
|
MediaTranscriptionPhase.TRANSCODING => $"{this.T("Preparing audio")}: {this.Snapshot.CurrentFileName}",
|
|
|
|
|
MediaTranscriptionPhase.UPLOADING => $"{this.T("Transcribing")}: {this.Snapshot.CurrentFileName}",
|
|
|
|
|
MediaTranscriptionPhase.CANCELING => $"{this.T("Stopping media transcription")}: {this.Snapshot.CurrentFileName}",
|
2026-07-14 07:00:30 +00:00
|
|
|
|
2026-07-14 12:41:13 +00:00
|
|
|
_ => this.Snapshot?.CurrentFileName ?? string.Empty,
|
2026-07-13 19:59:40 +00:00
|
|
|
};
|
|
|
|
|
|
2026-07-14 07:00:30 +00:00
|
|
|
/// <summary>Subscribes to singleton import state changes.</summary>
|
2026-07-13 19:59:40 +00:00
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
|
|
|
|
this.MediaTranscriptionService.StateChanged += this.OnStateChanged;
|
|
|
|
|
await base.OnInitializedAsync();
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-14 07:00:30 +00:00
|
|
|
/// <summary>Schedules a render after an import state transition.</summary>
|
2026-07-14 12:41:13 +00:00
|
|
|
private void OnStateChanged(MediaImportOwner owner)
|
|
|
|
|
{
|
|
|
|
|
if (owner == this.Owner)
|
|
|
|
|
_ = this.InvokeAsync(this.StateHasChanged);
|
|
|
|
|
}
|
2026-07-13 19:59:40 +00:00
|
|
|
|
2026-07-14 07:00:30 +00:00
|
|
|
/// <summary>Unsubscribes from singleton import state changes.</summary>
|
2026-07-13 19:59:40 +00:00
|
|
|
protected override void DisposeResources()
|
|
|
|
|
{
|
|
|
|
|
this.MediaTranscriptionService.StateChanged -= this.OnStateChanged;
|
2026-07-14 07:00:30 +00:00
|
|
|
base.DisposeResources();
|
2026-07-13 19:59:40 +00:00
|
|
|
}
|
|
|
|
|
}
|