True Streaming Support Draft

This commit is contained in:
daniel-c-harvey
2025-09-15 17:03:36 -04:00
parent 0fa8ac7379
commit 605fc94fbb
16 changed files with 1124 additions and 295 deletions
@@ -23,7 +23,7 @@ else
IsLoaded="IsLoaded"
TogglePlayPause="@TogglePlayPause"
Stop="@Stop"/>
@if (IsLoading)
@if (IsLoading && !IsStreaming)
{
<MudProgressCircular Color="Color.Tertiary"
Size="Size.Small"
@@ -58,7 +58,7 @@ else
IsLoaded="IsLoaded"
TogglePlayPause="@TogglePlayPause"
Stop="@Stop"/>
@if (IsLoading)
@if (IsLoading && !IsStreaming)
{
<MudProgressCircular Color="Color.Tertiary"
Size="Size.Small"
@@ -6,12 +6,13 @@ namespace DeepDrftWeb.Client.Controls.AudioPlayerBar;
public partial class AudioPlayerBar : ComponentBase
{
[CascadingParameter] public required IPlayerService PlayerService { get; set; }
[CascadingParameter] public required IStreamingPlayerService PlayerService { get; set; }
private bool _isMinimized = true;
private bool IsLoaded => PlayerService.IsLoaded;
private bool IsLoading => PlayerService.IsLoading;
private bool IsStreaming => PlayerService.CanStartStreaming;
private bool IsPlaying => PlayerService.IsPlaying;
private bool IsPaused => PlayerService.IsPaused;
private double CurrentTime => PlayerService.CurrentTime;
@@ -23,8 +24,8 @@ public partial class AudioPlayerBar : ComponentBase
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
PlayerService.OnStateChanged += StateHasChanged;
PlayerService.OnTrackSelected += Expand;
// Set up EventCallback for track selection
PlayerService.OnTrackSelected = new EventCallback(this, Expand);
}
private async Task Expand()
@@ -1,6 +1,7 @@
using DeepDrftWeb.Client.Services;
using DeepDrftWeb.Client.Clients;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Logging;
namespace DeepDrftWeb.Client.Controls;
@@ -8,15 +9,20 @@ public partial class AudioPlayerProvider : ComponentBase
{
[Inject] public required AudioInteropService AudioInterop { get; set; }
[Inject] public required TrackMediaClient TrackMediaClient { get; set; }
[Inject] public required ILogger<StreamingAudioPlayerService> Logger { get; set; }
private AudioPlayerService? _audioPlayerService;
private StreamingAudioPlayerService? _audioPlayerService;
[Parameter] public RenderFragment? ChildContent { get; set; }
protected override void OnInitialized()
{
// Create the service immediately (but don't initialize yet)
_audioPlayerService = new AudioPlayerService(AudioInterop, TrackMediaClient);
_audioPlayerService = new StreamingAudioPlayerService(AudioInterop, TrackMediaClient, Logger);
// Set up EventCallback to properly marshal UI updates back to UI thread
_audioPlayerService.OnStateChanged = new EventCallback(this, StateHasChanged);
// OnTrackSelected will be set by individual child components that need it
}
protected override async Task OnAfterRenderAsync(bool firstRender)