using DeepDrftModels.DTOs;
using Microsoft.AspNetCore.Components;
using NetBlocks.Models;
namespace DeepDrftPublic.Client.Services;
public interface IPlayerService
{
// State properties
bool IsInitialized { get; }
bool IsLoaded { get; }
bool IsLoading { get; }
bool IsPlaying { get; }
bool IsPaused { get; }
double CurrentTime { get; }
double? Duration { get; }
double Volume { get; }
double LoadProgress { get; }
string? ErrorMessage { get; }
TrackDto? CurrentTrack { get; }
///
/// Normalized loudness profile for the current track, each value in [0, 1], or null when no
/// profile is available (no track loaded, or the track has no stored profile). The seek zone
/// renders this as a waveform; a null profile drives the flat-but-seekable fallback. Fetched on
/// track select and cleared on unload/stop; fires once it arrives.
///
double[]? WaveformProfile { get; }
// Events for UI updates
EventCallback? OnStateChanged { get; set; }
EventCallback? OnTrackSelected { get; set; }
///
/// Multicast side-channel for state changes. The provider owns the single
/// EventCallback (it drives the provider re-render);
/// cascade consumers that read state directly off this service — and so are not
/// re-rendered by the provider's render when the cascade is IsFixed —
/// subscribe here to re-render themselves. Fires on the same cadence as
/// (throttled to ~10/s during streaming).
///
event Action? StateChanged;
// Control methods
Task InitializeAsync();
Task SelectTrack(TrackDto track);
Task Stop();
Task Unload();
Task TogglePlayPause();
Task Seek(double position);
Task SetVolume(double volume);
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(TrackDto track);
}