diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index e0ee5b0..4de349b 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -104,28 +104,17 @@ public partial class MainWindow : Window
private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
- InitializePlayer();
+ // Core.Initialize lädt libVLC-Natives (~5-10s) und blockiert sonst den UI-Thread.
+ // Natives auf Background-Thread, UI-Zuweisung (VideoView) danach auf UI-Thread.
+ await Task.Run(InitializePlayerNatives);
+ InitializePlayerUi();
await LoadChannelsAsync();
RestoreLastChannel();
-
- // EPG im Hintergrund laden — wird für "Danach"-Anzeige und EPG-Overlay gebraucht
_ = LoadEpgInBackgroundAsync();
}
- private async Task LoadEpgInBackgroundAsync()
- {
- if (_epgService.IsCurrent) return;
- try
- {
- await _epgService.LoadAsync();
- // Nach EPG-Load: "Danach" für aktuellen Sender setzen
- if (_currentChannel != null)
- Dispatcher.BeginInvoke(() => UpdateNextFromEpgService(_currentChannel));
- }
- catch { }
- }
-
- private void InitializePlayer()
+ /// Schritt 1 (Background-Thread): libVLC-Natives laden. Kein UI-Zugriff.
+ private void InitializePlayerNatives()
{
var exeDir = Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().Location)!;
@@ -139,12 +128,28 @@ public partial class MainWindow : Window
"--no-video-title-show",
"--no-osd",
"--no-snapshot-preview",
- "--rtsp-tcp" // RTP over TCP: stabilere Sessions, vermeidet UDP-Routing-Kollisionen
- // wenn mehrere Instanzen parallel auf die gleiche FritzBox zugreifen
+ "--rtsp-tcp"
);
_player = new MediaPlayer(_libVLC);
+ _player.Volume = (int)SldVolume.Value; // Value-Lesen ist thread-safe (DependencyProperty)
+ }
+
+ /// Schritt 2 (UI-Thread): MediaPlayer an VideoView binden.
+ private void InitializePlayerUi()
+ {
VideoView.MediaPlayer = _player;
- _player.Volume = (int)SldVolume.Value;
+ }
+
+ private async Task LoadEpgInBackgroundAsync()
+ {
+ if (_epgService.IsCurrent) return;
+ try
+ {
+ await _epgService.LoadAsync();
+ if (_currentChannel != null)
+ Dispatcher.BeginInvoke(() => UpdateNextFromEpgService(_currentChannel));
+ }
+ catch { }
}
private void MainWindow_Closing(object? sender, CancelEventArgs e)