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