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
@@ -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);
}