AUdio Player Service refactor

This commit is contained in:
daniel-c-harvey
2025-09-08 14:20:38 -04:00
parent bf054f3d1b
commit a25d067dff
14 changed files with 323 additions and 158 deletions
@@ -0,0 +1,33 @@
using DeepDrftWeb.Client.Services;
using Microsoft.AspNetCore.Components;
using DeepDrftModels.Entities;
namespace DeepDrftWeb.Client.Controls;
public partial class AudioPlayerService : ComponentBase
{
[Inject] public required AudioPlaybackEngine AudioPlaybackEngine { get; set; }
private readonly PlayerService _playerService = new();
private IPlayerService PlayerService => _playerService;
[Parameter] public RenderFragment? ChildContent { get; set; }
protected override void OnInitialized()
{
base.OnInitialized();
// PlayerService is already created as a field, so it's immediately available to cascading components
// It will be in uninitialized state until OnAfterRenderAsync when AudioPlaybackEngine is ready
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
// Initialize the PlayerService with the AudioPlaybackEngine now that it's available
await _playerService.InitializeAsync(AudioPlaybackEngine);
StateHasChanged();
}
}
}