diff --git a/README.md b/README.md index bb2fe56..cfa7d0c 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,14 @@ **Kick.com için Modern Masaüstü Canlı Yayın İzleme Stüdyosu ve Sohbet İstemcisi** -[![Release](https://img.shields.io/badge/Release-v1.4.0-53FC18?style=for-the-badge&logo=github)](https://github.com/LilDosto/LD-KickWatch/releases/latest) +[![Release](https://img.shields.io/badge/Release-v1.5.0-53FC18?style=for-the-badge&logo=github)](https://github.com/LilDosto/LD-KickWatch/releases/latest) [![Platform](https://img.shields.io/badge/Platform-Windows%2010%20%2F%2011%20(x64)-0078D6?style=for-the-badge&logo=windows)](https://github.com/LilDosto/LD-KickWatch) [![.NET](https://img.shields.io/badge/.NET-8.0%20WPF-512BD4?style=for-the-badge&logo=dotnet)](https://dotnet.microsoft.com/download/dotnet/8.0) [![License](https://img.shields.io/badge/Lisans-MIT-53FC18?style=for-the-badge)](./LICENSE) Favori **Kick.com** yayıncılarınızı takip edin, anlık canlı yayın ve kategori bildirimleri alın, **Pencere İçi Web Oynatıcı (WebView2)** veya **Pencere İçi Gömülü VLC** ile yayınları izleyin, **2x2 Çoklu Yayın (Squad View)** modunda 4 yayını aynı anda takip edin ve gerçek **Kick Emote** destekli canlı sohbete bağlanın. -[📦 **Son Sürümü İndir (v1.4.0 Releases)**](https://github.com/LilDosto/LD-KickWatch/releases/latest) • [🚀 **Özellikler**](#-başlıca-özellikler) • [⌨ **Kısayollar**](#-klavye-kısayolları) • [🛠 **Derleme**](#-kaynak-koddan-derleme) +[📦 **Son Sürümü İndir (v1.5.0 Releases)**](https://github.com/LilDosto/LD-KickWatch/releases/latest) • [🚀 **Özellikler**](#-başlıca-özellikler) • [⌨ **Kısayollar**](#-klavye-kısayolları) • [🛠 **Derleme**](#-kaynak-koddan-derleme) @@ -130,6 +130,11 @@ LD-KickWatch/ ## 🆕 Sürüm Geçmişi +### 🟢 v1.5.0 (28 Ekim 2026) +- **⚡ Akıcı ve Kesintisiz Canlı Sohbet (Background Dispatcher & Batching):** Canlı sohbette mesajların birkaç saniye sonra tıkanması ve akmaması sorunu tamamen çözüldü. Gelen mesajlar non-blocking kuyruk (`ConcurrentQueue`) ve 75 ms toplu arka plan işleme (`DispatcherTimer`) ile UI'ya aktarılıyor; 100.000 izleyicili yayınlarda dahi sohbet su gibi akıyor. +- **🛡 UI Virtualization Entegrasyonu:** Sohbet kutusuna UI sanallaştırma ve geri dönüşüm (`Recycling`) eklendi, gereksiz DOM ölçümleri ve CPU darboğazı ortadan kaldırıldı. +- **🎯 Havada Kalan/Bozulan Kalite Menüsü Yerel Açılır Menüye (ContextMenu) Taşındı:** WinForms (`WindowsFormsHost` / `VlcPanel`) ve WebView2 üzerindeki WPF Airspace (saydam popup çakışması) nedeniyle oluşan donma ve bug'lar tamamen giderildi. Artık YouTube/Twitch tarzı tıklandığında anında açılan, seçili kaliteyi tik işaretiyle (✓) gösteren şık ve sıfır hatalı bir kalite menüsü bulunuyor. + ### 🟢 v1.4.0 (28 Ekim 2026) - **💬 Canlı Sohbet Bağlantı Sorunu Düzeltildi:** Kick'in yenilediği güncel Pusher WebSocket protokolü ve anahtarı entegre edildi. Artık tüm yayıncıların canlı sohbet akışları anında ve kesintisiz bağlanıyor. - **🔍 Kalite Seçim Kutusu Büyütüldü ve Ferahlatıldı:** Oynatıcı çubuğundaki kalite kutucuğu genişletildi, yazıların dikey/yatay kırpılması ve sıkışıklık tamamen giderildi; okunabilir, şık ve ferah bir tasarıma kavuşturuldu. diff --git a/src/KickStreamHub/KickStreamHub.csproj b/src/KickStreamHub/KickStreamHub.csproj index 5f9bc72..b3933f6 100644 --- a/src/KickStreamHub/KickStreamHub.csproj +++ b/src/KickStreamHub/KickStreamHub.csproj @@ -9,9 +9,9 @@ enable KickStreamHub LDKickWatch - 1.4.0 - 1.4.0.0 - 1.4.0.0 + 1.5.0 + 1.5.0.0 + 1.5.0.0 LD KickWatch LD KickWatch LD KickWatch diff --git a/src/KickStreamHub/Services/PusherChatService.cs b/src/KickStreamHub/Services/PusherChatService.cs index 7b61448..a9f1005 100644 --- a/src/KickStreamHub/Services/PusherChatService.cs +++ b/src/KickStreamHub/Services/PusherChatService.cs @@ -186,7 +186,7 @@ public sealed partial class PusherChatService : IAsyncDisposable break; } } - catch (JsonException ex) + catch (Exception ex) { LoggingService.Instance.Warning($"Sohbet mesajı ayrıştırılamadı: {ex.Message}"); } @@ -194,39 +194,46 @@ public sealed partial class PusherChatService : IAsyncDisposable private void HandleChatMessagePayload(JsonElement root) { - if (!root.TryGetProperty("data", out var dataEl)) return; - var dataRaw = dataEl.GetString(); - if (string.IsNullOrEmpty(dataRaw)) return; - - using var innerDoc = JsonDocument.Parse(dataRaw); - var inner = innerDoc.RootElement; - - var rawContent = inner.TryGetProperty("content", out var c) ? c.GetString() ?? string.Empty : string.Empty; - var content = KickEmoteRegex().Replace(rawContent, ":$1:"); - - var sender = inner.TryGetProperty("sender", out var s) ? s : default; - - var username = "?"; - var color = "#53FC18"; - if (sender.ValueKind == JsonValueKind.Object) + try { - if (sender.TryGetProperty("username", out var u)) username = u.GetString() ?? "?"; - if (sender.TryGetProperty("identity", out var identity) && - identity.TryGetProperty("color", out var colorEl)) + if (!root.TryGetProperty("data", out var dataEl)) return; + var dataRaw = dataEl.GetString(); + if (string.IsNullOrEmpty(dataRaw)) return; + + using var innerDoc = JsonDocument.Parse(dataRaw); + var inner = innerDoc.RootElement; + + var rawContent = inner.TryGetProperty("content", out var c) ? c.GetString() ?? string.Empty : string.Empty; + var content = KickEmoteRegex().Replace(rawContent, ":$1:"); + + var sender = inner.TryGetProperty("sender", out var s) ? s : default; + + var username = "?"; + var color = "#53FC18"; + if (sender.ValueKind == JsonValueKind.Object) { - var parsedColor = colorEl.GetString(); - if (!string.IsNullOrWhiteSpace(parsedColor)) - color = parsedColor; + if (sender.TryGetProperty("username", out var u)) username = u.GetString() ?? "?"; + if (sender.TryGetProperty("identity", out var identity) && + identity.TryGetProperty("color", out var colorEl)) + { + var parsedColor = colorEl.GetString(); + if (!string.IsNullOrWhiteSpace(parsedColor)) + color = parsedColor; + } } - } - MessageReceived?.Invoke(this, new ChatMessageEventArgs + MessageReceived?.Invoke(this, new ChatMessageEventArgs + { + Username = username, + Message = content, + RawMessage = rawContent, + ColorHex = color, + }); + } + catch (Exception ex) { - Username = username, - Message = content, - RawMessage = rawContent, - ColorHex = color, - }); + LoggingService.Instance.Warning($"Sohbet yükü işlenemedi: {ex.Message}"); + } } private async Task SubscribeToChatroomAsync(CancellationToken ct) diff --git a/src/KickStreamHub/ViewModels/ChatViewModel.cs b/src/KickStreamHub/ViewModels/ChatViewModel.cs index b98ace7..8774604 100644 --- a/src/KickStreamHub/ViewModels/ChatViewModel.cs +++ b/src/KickStreamHub/ViewModels/ChatViewModel.cs @@ -1,3 +1,4 @@ +using System.Collections.Concurrent; using System.Collections.ObjectModel; using System.Windows.Threading; using CommunityToolkit.Mvvm.ComponentModel; @@ -20,6 +21,9 @@ public partial class ChatViewModel : ObservableObject, IAsyncDisposable { private readonly PusherChatService _chatService = new(); private readonly Dispatcher _dispatcher; + private readonly ConcurrentQueue _incomingQueue = new(); + private readonly DispatcherTimer _batchTimer; + public int MaxMessages { get; set; } = 500; [ObservableProperty] private string _channelName = string.Empty; @@ -35,12 +39,51 @@ public partial class ChatViewModel : ObservableObject, IAsyncDisposable public ObservableCollection Messages { get; } = new(); public ObservableCollection FilteredMessages { get; } = new(); + public event EventHandler? NewMessagesAppended; + public ChatViewModel() { _dispatcher = Dispatcher.CurrentDispatcher; _chatService.MessageReceived += OnMessageReceived; _chatService.ConnectionStateChanged += (_, connected) => _dispatcher.BeginInvoke(() => IsConnected = connected); + + _batchTimer = new DispatcherTimer(DispatcherPriority.Background, _dispatcher) + { + Interval = TimeSpan.FromMilliseconds(75) + }; + _batchTimer.Tick += BatchTimer_Tick; + _batchTimer.Start(); + } + + private void BatchTimer_Tick(object? sender, EventArgs e) + { + if (_incomingQueue.IsEmpty) return; + + bool hasAppended = false; + int processed = 0; + while (_incomingQueue.TryDequeue(out var item) && processed < 40) + { + processed++; + Messages.Add(item); + while (Messages.Count > MaxMessages) + Messages.RemoveAt(0); + + if (!IsPaused && MatchesFilter(item)) + { + FilteredMessages.Add(item); + while (FilteredMessages.Count > MaxMessages) + FilteredMessages.RemoveAt(0); + hasAppended = true; + } + } + + MessageCount = Messages.Count; + + if (hasAppended && !IsPaused) + { + NewMessagesAppended?.Invoke(this, EventArgs.Empty); + } } public async Task ConnectAsync(string channelName, long chatroomId) @@ -50,9 +93,12 @@ public partial class ChatViewModel : ObservableObject, IAsyncDisposable ChannelName = channelName; ChatroomId = chatroomId; + + while (_incomingQueue.TryDequeue(out _)) { } Messages.Clear(); FilteredMessages.Clear(); MessageCount = 0; + if (chatroomId > 0) await _chatService.ConnectAsync(chatroomId); } @@ -65,29 +111,19 @@ public partial class ChatViewModel : ObservableObject, IAsyncDisposable private void OnMessageReceived(object? sender, ChatMessageEventArgs e) { - var item = new ChatMessageItem + try { - Username = e.Username, - Message = e.Message, - RawMessage = string.IsNullOrEmpty(e.RawMessage) ? e.Message : e.RawMessage, - ColorHex = e.ColorHex, - }; - - _dispatcher.BeginInvoke(() => - { - Messages.Add(item); - while (Messages.Count > MaxMessages) - Messages.RemoveAt(0); - - MessageCount = Messages.Count; - - if (!IsPaused && MatchesFilter(item)) + var item = new ChatMessageItem { - FilteredMessages.Add(item); - while (FilteredMessages.Count > MaxMessages) - FilteredMessages.RemoveAt(0); - } - }); + Username = e.Username, + Message = e.Message, + RawMessage = string.IsNullOrEmpty(e.RawMessage) ? e.Message : e.RawMessage, + ColorHex = e.ColorHex, + }; + + _incomingQueue.Enqueue(item); + } + catch { } } private bool MatchesFilter(ChatMessageItem item) @@ -122,6 +158,7 @@ public partial class ChatViewModel : ObservableObject, IAsyncDisposable [RelayCommand] private void ClearMessages() { + while (_incomingQueue.TryDequeue(out _)) { } Messages.Clear(); FilteredMessages.Clear(); MessageCount = 0; @@ -129,6 +166,7 @@ public partial class ChatViewModel : ObservableObject, IAsyncDisposable public async ValueTask DisposeAsync() { + _batchTimer.Stop(); await _chatService.DisposeAsync(); } } diff --git a/src/KickStreamHub/ViewModels/MainViewModel.cs b/src/KickStreamHub/ViewModels/MainViewModel.cs index b778234..a726ea0 100644 --- a/src/KickStreamHub/ViewModels/MainViewModel.cs +++ b/src/KickStreamHub/ViewModels/MainViewModel.cs @@ -88,6 +88,36 @@ public partial class MainViewModel : ObservableObject [ObservableProperty] private string _activePlayerChannel = string.Empty; [ObservableProperty] private string _selectedQuality = "best"; + public string SelectedQualityDisplay => SelectedQuality switch + { + "best" => "Kaynak (En İyi)", + "1080p60" => "1080p 60 FPS", + "720p60" => "720p 60 FPS", + "720p" => "720p", + "480p" => "480p", + "360p" => "360p", + "160p" => "160p", + "worst" => "En Düşük", + "audio_only" => "Sadece Ses", + _ => SelectedQuality + }; + + public void SetStreamQuality(string quality) + { + if (string.IsNullOrWhiteSpace(quality)) return; + if (string.Equals(SelectedQuality, quality, StringComparison.OrdinalIgnoreCase)) return; + + SelectedQuality = quality; + OnPropertyChanged(nameof(SelectedQualityDisplay)); + Config.StreamQuality = quality; + _configService.Save(Config); + + if (IsEmbeddedPlaying && IsEmbeddedVlcActive && !string.IsNullOrEmpty(ActivePlayerChannel)) + { + _ = PlayEmbeddedVlcPlayerAsync(ActivePlayerChannel); + } + } + // Multi-Stream (Squad View) bindings [ObservableProperty] private bool _isQuadLayout = true; @@ -192,14 +222,7 @@ public partial class MainViewModel : ObservableObject partial void OnSelectedQualityChanged(string value) { - if (string.IsNullOrWhiteSpace(value)) return; - Config.StreamQuality = value; - _configService.Save(Config); - - if (IsEmbeddedPlaying && IsEmbeddedVlcActive && !string.IsNullOrEmpty(ActivePlayerChannel)) - { - _ = PlayEmbeddedVlcPlayerAsync(ActivePlayerChannel); - } + OnPropertyChanged(nameof(SelectedQualityDisplay)); } [RelayCommand] diff --git a/src/KickStreamHub/Views/ChatWindow.xaml.cs b/src/KickStreamHub/Views/ChatWindow.xaml.cs index 127cbb5..4296a11 100644 --- a/src/KickStreamHub/Views/ChatWindow.xaml.cs +++ b/src/KickStreamHub/Views/ChatWindow.xaml.cs @@ -17,17 +17,20 @@ public partial class ChatWindow : Window Loaded += async (_, _) => await _vm.ConnectAsync(channelName, chatroomId); Closed += async (_, _) => await _vm.DisposeAsync(); - _vm.FilteredMessages.CollectionChanged += AutoScrollToBottom; + _vm.NewMessagesAppended += (_, _) => AutoScrollToBottom(); } - private void AutoScrollToBottom(object? sender, NotifyCollectionChangedEventArgs e) + private void AutoScrollToBottom() { if (_vm.IsPaused) return; - if ((e.Action == NotifyCollectionChangedAction.Add || e.Action == NotifyCollectionChangedAction.Reset) - && ChatListBox.Items.Count > 0) + try { - ChatListBox.ScrollIntoView(ChatListBox.Items[^1]); + if (ChatListBox.Items.Count > 0) + { + ChatListBox.ScrollIntoView(ChatListBox.Items[^1]); + } } + catch { } } } diff --git a/src/KickStreamHub/Views/MainWindow.xaml b/src/KickStreamHub/Views/MainWindow.xaml index 1b08c4a..ec66713 100644 --- a/src/KickStreamHub/Views/MainWindow.xaml +++ b/src/KickStreamHub/Views/MainWindow.xaml @@ -488,36 +488,33 @@ - - + + @@ -752,7 +749,9 @@ ItemsSource="{Binding FilteredMessages}" Background="Transparent" BorderThickness="0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" - ScrollViewer.CanContentScroll="False" + ScrollViewer.CanContentScroll="True" + VirtualizingPanel.IsVirtualizing="True" + VirtualizingPanel.VirtualizationMode="Recycling" VirtualizingPanel.ScrollUnit="Pixel"> diff --git a/src/KickStreamHub/Views/MainWindow.xaml.cs b/src/KickStreamHub/Views/MainWindow.xaml.cs index f94d0c5..e9d8d81 100644 --- a/src/KickStreamHub/Views/MainWindow.xaml.cs +++ b/src/KickStreamHub/Views/MainWindow.xaml.cs @@ -2,6 +2,7 @@ using System.Collections.Specialized; using System.ComponentModel; using System.IO; using System.Windows; +using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using KickStreamHub.Services; @@ -44,7 +45,7 @@ public partial class MainWindow : Window _viewModel.MultiSlotStopRequested += ViewModel_MultiSlotStopRequested; _viewModel.MultiSlotMuteRequested += ViewModel_MultiSlotMuteRequested; - _viewModel.EmbeddedChat.FilteredMessages.CollectionChanged += EmbeddedChat_CollectionChanged; + _viewModel.EmbeddedChat.NewMessagesAppended += EmbeddedChat_NewMessagesAppended; _notifications.OpenRequested += (_, _) => RestoreAndBringToFront(); _notifications.ExitRequested += (_, _) => Close(); @@ -296,14 +297,17 @@ public partial class MainWindow : Window // ==================== EMBEDDED CHAT AUTO-SCROLL ==================== - private void EmbeddedChat_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) + private void EmbeddedChat_NewMessagesAppended(object? sender, EventArgs e) { if (_viewModel.EmbeddedChat.IsPaused) return; - if ((e.Action == NotifyCollectionChangedAction.Add || e.Action == NotifyCollectionChangedAction.Reset) && - EmbeddedChatListBox.Items.Count > 0) + try { - EmbeddedChatListBox.ScrollIntoView(EmbeddedChatListBox.Items[^1]); + if (EmbeddedChatListBox.Items.Count > 0) + { + EmbeddedChatListBox.ScrollIntoView(EmbeddedChatListBox.Items[^1]); + } } + catch { } } private void OnViewModelPropertyChanged(object? sender, PropertyChangedEventArgs e) @@ -379,6 +383,33 @@ public partial class MainWindow : Window Focus(); } + private void QualityButton_Click(object sender, RoutedEventArgs e) + { + if (sender is FrameworkElement fe && fe.ContextMenu != null) + { + foreach (var item in fe.ContextMenu.Items.OfType()) + { + var isCurrent = string.Equals(item.Tag as string, _viewModel.SelectedQuality, StringComparison.OrdinalIgnoreCase); + var headerStr = item.Header?.ToString() ?? string.Empty; + var clean = headerStr.Replace("✓", "", StringComparison.Ordinal).Trim(); + item.Header = isCurrent ? $"✓ {clean}" : $" {clean}"; + item.FontWeight = isCurrent ? FontWeights.Bold : FontWeights.Normal; + } + + fe.ContextMenu.PlacementTarget = fe; + fe.ContextMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom; + fe.ContextMenu.IsOpen = true; + } + } + + private void QualityMenuItem_Click(object sender, RoutedEventArgs e) + { + if (sender is System.Windows.Controls.MenuItem mi && mi.Tag is string q) + { + _viewModel.SetStreamQuality(q); + } + } + private void MainWindow_Closing(object? sender, CancelEventArgs e) { // Pencere kapatıldığında (X veya Alt+F4) uygulama arkaplanda açık kalmaz,