From 41a9d2700559cd4ce9b5e195815bd953523fb10f Mon Sep 17 00:00:00 2001 From: FrigaT Date: Thu, 16 Apr 2026 04:35:05 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D1=81=D0=B2=D0=BE=D0=B5=D0=B3=D0=BE=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B3=D1=80=D0=B5=D1=81=D1=81=D0=B0=20=D0=B7=D0=B0=D0=B3?= =?UTF-8?q?=D1=80=D1=83=D0=B7=D0=BA=D0=B8=20=D1=82=D1=80=D0=B5=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Global/AudioPlayer.razor | 10 +- .../Components/Global/TrackProgress.razor | 137 ++++++++++++++++++ 2 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 PlaylistShared.Pwa/Components/Global/TrackProgress.razor diff --git a/PlaylistShared.Pwa/Components/Global/AudioPlayer.razor b/PlaylistShared.Pwa/Components/Global/AudioPlayer.razor index 5d548ff..1f30198 100644 --- a/PlaylistShared.Pwa/Components/Global/AudioPlayer.razor +++ b/PlaylistShared.Pwa/Components/Global/AudioPlayer.razor @@ -39,6 +39,12 @@ + + @@ -60,6 +66,7 @@ Class="pa-0 mt-n5" Style="height:120px; width: 10px; background-color: transparent !important; overflow: visible !important;"> + @@ -78,6 +85,7 @@ // Громкость private bool _volumeIsOpen; private double _volumeBeforeMute; + private double _bufferValue; private bool _isPlayHovered; @@ -125,7 +133,7 @@ [JSInvokable] public async Task OnDownloadProgress(double second) { - var x = second; + _bufferValue = second / AudioPlayerService.TotalTime * 100; } private async Task CheckAuthAsync() diff --git a/PlaylistShared.Pwa/Components/Global/TrackProgress.razor b/PlaylistShared.Pwa/Components/Global/TrackProgress.razor new file mode 100644 index 0000000..0f0ed04 --- /dev/null +++ b/PlaylistShared.Pwa/Components/Global/TrackProgress.razor @@ -0,0 +1,137 @@ +
+ @* Фоновая дорожка *@ +
+ @* Буфер *@ +
+ @* Активная шкала (заполнение) *@ +
+
+ + @* Ползунок *@ + +
+ + + +@code { + [Parameter] public double Value { get; set; } + [Parameter] public double BufferValue { get; set; } + [Parameter] public double Min { get; set; } = 0; + [Parameter] public double Max { get; set; } = 100; + [Parameter] public Color Color { get; set; } = Color.Primary; + [Parameter] public EventCallback ValueChanged { get; set; } + + // Генерируем CSS класс на основе перечисления Color + private string ColorClass => $"track-color-{Color.ToString().ToLower()}"; + + private async Task OnInput(ChangeEventArgs e) + { + if (double.TryParse(e.Value?.ToString(), System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out var newValue)) + { + await ValueChanged.InvokeAsync(newValue); + } + } + + private async Task HandleWheel(WheelEventArgs e) + { + double range = Max - Min; + double step = range * 0.02; + var newValue = e.DeltaY < 0 ? Math.Min(Value + step, Max) : Math.Max(Value - step, Min); + await ValueChanged.InvokeAsync(newValue); + } + + private double CalculatePercentage(double val) + { + if (Max <= Min) return 0; + return ((Math.Clamp(val, Min, Max) - Min) / (Max - Min)) * 100; + } +} \ No newline at end of file