using DeepDrftModels.DTOs; using DeepDrftPublic.Client.Services; using Microsoft.AspNetCore.Components; namespace DeepDrftPublic.Client.Controls; /// /// Shared detail-page chrome for any release medium: back link, masthead, play/share affordance, /// and hero/meta slots. Owns the play-toggle wiring against the cascaded streaming player so each /// detail page supplies only its data and medium-specific visuals. Extracted from the original /// TrackDetail page, which is now a thin consumer of this scaffold. /// public partial class ReleaseDetailScaffold : ComponentBase { [CascadingParameter] public IStreamingPlayerService? PlayerService { get; set; } [Parameter] public required string Title { get; set; } [Parameter] public string? Artist { get; set; } // The playable track for this release. Null while unresolved (or when a release has no // streamable track yet) — the play/share row is hidden in that case. [Parameter] public TrackDto? Track { get; set; } [Parameter] public string BackHref { get; set; } = "/archive"; [Parameter] public string BackLabel { get; set; } = "Archive"; /// /// Optional medium-specific content rendered between the back link and the masthead — the "below /// the back button, above the details" band. The Mix detail page uses it for the visualizer /// controls row; other media leave it null. /// [Parameter] public RenderFragment? TopContent { get; set; } /// Medium-specific hero visual (cover art, hero image, or waveform background). [Parameter] public RenderFragment? Hero { get; set; } /// Optional medium-specific metadata block, rendered under a divider when present. [Parameter] public RenderFragment? MetaContent { get; set; } /// /// Gate for the metadata block. Lets a consumer supply a fragment but /// suppress the divider + block when its data is empty (slot fragments cannot be conditionally /// attached inline). Defaults to shown. /// [Parameter] public bool ShowMeta { get; set; } = true; private async Task PlayTrack() { if (Track is null || PlayerService is null) return; // Toggle if this track is already active (playing or paused); otherwise start a fresh // stream. SelectTrackStreaming is the live entry point — the buffered path is dead. var isThisTrack = PlayerService.CurrentTrack?.Id == Track.Id; if (isThisTrack && (PlayerService.IsPlaying || PlayerService.IsPaused)) { await PlayerService.TogglePlayPause(); } else { await PlayerService.SelectTrackStreaming(Track); } } }