Front End Streaming Playback Improvements

This commit is contained in:
daniel-c-harvey
2025-09-13 15:22:26 -04:00
parent cdeb300d5e
commit 0fa8ac7379
8 changed files with 417 additions and 11 deletions
@@ -3,7 +3,7 @@ using NetBlocks.Models;
namespace DeepDrftWeb.Client.Clients;
public class TrackMediaResponse
public class TrackMediaResponse : IDisposable
{
public Stream Stream { get; }
public long ContentLength { get; }
@@ -13,6 +13,11 @@ public class TrackMediaResponse
Stream = stream;
ContentLength = contentLength;
}
public void Dispose()
{
Stream?.Dispose();
}
}
public class TrackMediaClient
+1 -1
View File
@@ -7,7 +7,7 @@
@* Hero Section *@
<MudPaper Elevation="0" Class="pa-8 mb-6 text-center deepdrft-gradient-hero deepdrft-hero-container">
<MudGrid Justify="Justify.Center" AlignItems="Center">
<MudGrid Justify="Justify.Center">
<MudItem xs="12" md="8">
<MudText Typo="Typo.h1" Color="Color.Surface"
Class="mb-4 deepdrft-text-hero">
@@ -40,6 +40,21 @@ public class AudioInteropService : IAsyncDisposable
return await InvokeJsAsync<AudioLoadResult>("DeepDrftAudio.finalizeAudioBuffer", playerId);
}
// Streaming methods
public async Task<AudioOperationResult> InitializeStreaming(string playerId)
{
return await InvokeJsAsync<AudioOperationResult>("DeepDrftAudio.initializeStreaming", playerId);
}
public async Task<StreamingResult> ProcessStreamingChunk(string playerId, byte[] audioChunk)
{
return await InvokeJsAsync<StreamingResult>("DeepDrftAudio.processStreamingChunk", playerId, audioChunk);
}
public async Task<AudioOperationResult> StartStreamingPlayback(string playerId)
{
return await InvokeJsAsync<AudioOperationResult>("DeepDrftAudio.startStreamingPlayback", playerId);
}
public async Task<AudioOperationResult> PlayAsync(string playerId)
{
@@ -216,6 +231,13 @@ public class AudioLoadResult : AudioOperationResult
public double LoadProgress { get; set; }
}
public class StreamingResult : AudioOperationResult
{
public bool CanStartStreaming { get; set; }
public bool HeaderParsed { get; set; }
public int BufferCount { get; set; }
}
public class AudioPlayerState
{
public bool IsPlaying { get; set; }
+16 -3
View File
@@ -1,4 +1,5 @@
using DeepDrftModels.Entities;
using Microsoft.AspNetCore.Components;
using NetBlocks.Models;
namespace DeepDrftWeb.Client.Services;
@@ -18,8 +19,8 @@ public interface IPlayerService
string? ErrorMessage { get; }
// Events for UI updates
event Action? OnStateChanged;
event Events.EventAsync OnTrackSelected;
EventCallback? OnStateChanged { get; set; }
EventCallback? OnTrackSelected { get; set; }
// Control methods
Task InitializeAsync();
@@ -29,5 +30,17 @@ public interface IPlayerService
Task TogglePlayPause();
Task Seek(double position);
Task SetVolume(double volume);
void ClearError();
Task ClearError();
}
public interface IStreamingPlayerService : IPlayerService
{
// Streaming state properties
bool IsStreamingMode { get; }
bool CanStartStreaming { get; }
bool HeaderParsed { get; }
int BufferedChunks { get; }
// Streaming control methods
Task SelectTrackStreaming(TrackEntity track);
}