@using Microsoft.AspNetCore.Components.Web
@if (_isHovered || IsPlaying)
{
}
@code {
[Parameter] public string CoverUrl { get; set; } = string.Empty;
[Parameter] public string TrackId { get; set; } = string.Empty;
[Parameter] public bool IsPlaying { get; set; } = false;
[Parameter] public EventCallback OnPlay { get; set; }
[Parameter] public int Height { get; set; } = 50;
[Parameter] public int Width { get; set; } = 50;
private bool _isHovered;
private void HandleMouseEnter() => _isHovered = true;
private void HandleMouseLeave() => _isHovered = false;
private async Task OnPlayClick()
{
await OnPlay.InvokeAsync(TrackId);
}
private string FormatCoverUrl(string? url)
{
if (string.IsNullOrEmpty(url)) return "";
return "https://" + url.Replace("%%", $"{Width}x{Height}");
}
}