diff --git a/MainWindow.xaml b/MainWindow.xaml
index 11eb2cf..c38a19c 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -381,6 +381,9 @@
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 6acf5b1..bb851d4 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -42,6 +42,11 @@ public partial class MainWindow : Window
// WebView2 für Web-Sender (YouTube, Netflix etc.)
private bool _webViewReady = false;
+ // Aufnahme
+ private MediaPlayer? _recordPlayer;
+ private Media? _recordMedia;
+ private bool _isRecording = false;
+
// WndProc-Hook für globale Tastatureingaben (auch wenn WebView2 Fokus hat)
private System.Windows.Interop.HwndSource? _hwndSource;
@@ -206,6 +211,7 @@ public partial class MainWindow : Window
try
{
_hwndSource?.RemoveHook(WndProc);
+ if (_isRecording) StopRecording();
_epgTimer.Stop();
_zapTimer.Stop();
_epgRefreshTimer.Stop();
@@ -392,6 +398,8 @@ public partial class MainWindow : Window
TxtChannelSource.Foreground = ch.Source == ChannelSource.Online
? new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0x00, 0x78, 0xD4))
: new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0x66, 0xBB, 0x6A));
+ // Aufnahme stoppen wenn Sender wechselt
+ if (_isRecording) StopRecording();
TxtNoChannel.Visibility = Visibility.Collapsed;
UpdateFavButton();
@@ -687,6 +695,86 @@ public partial class MainWindow : Window
private void BtnFullscreen_Click(object sender, RoutedEventArgs e) => ToggleFullscreen();
+ private void BtnRecord_Click(object sender, RoutedEventArgs e)
+ {
+ if (_isRecording) StopRecording();
+ else StartRecording();
+ }
+
+ private void StartRecording()
+ {
+ if (_currentChannel == null || _currentChannel.Kind == ChannelKind.Web)
+ {
+ MessageBox.Show("Aufnahme nur für TV- und Radio-Sender möglich.",
+ "HomeStream", MessageBoxButton.OK, MessageBoxImage.Information);
+ return;
+ }
+
+ try
+ {
+ // Zieldatei: Sendername + Zeitstempel.ts
+ var dir = _settings.RecordingPath;
+ Directory.CreateDirectory(dir);
+ var safeName = string.Join("_", _currentChannel.Name.Split(Path.GetInvalidFileNameChars()));
+ var fileName = $"{safeName}_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.ts";
+ var filePath = Path.Combine(dir, fileName);
+
+ // Separater MediaPlayer nur für Aufnahme (kein Video-Output)
+ // Stream wird direkt von der Quelle aufgenommen, nicht vom laufenden Player
+ _recordMedia = new Media(_libVLC!, new Uri(_currentChannel.Url),
+ $":sout=#file{{dst={filePath}}}",
+ ":sout-keep",
+ ":network-caching=300");
+
+ _recordPlayer = new MediaPlayer(_libVLC!);
+ _recordPlayer.Media = _recordMedia;
+ _recordPlayer.Play();
+
+ _isRecording = true;
+ BtnRecord.Foreground = new System.Windows.Media.SolidColorBrush(
+ System.Windows.Media.Colors.Red);
+ BtnRecord.ToolTip = $"Aufnahme läuft: {fileName} — Klicken zum Stoppen";
+ TxtChannelSource.Text = (_currentChannel.Source == ChannelSource.Online ? "● Online" : "● FritzBox")
+ + " 🔴 REC";
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"Aufnahme-Fehler:\n{ex.Message}",
+ "HomeStream", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ private void StopRecording()
+ {
+ try
+ {
+ _recordPlayer?.Stop();
+ _recordPlayer?.Dispose();
+ _recordMedia?.Dispose();
+ }
+ catch { }
+ finally
+ {
+ _recordPlayer = null;
+ _recordMedia = null;
+ _isRecording = false;
+ BtnRecord.Foreground = new System.Windows.Media.SolidColorBrush(
+ System.Windows.Media.Color.FromRgb(0x88, 0x88, 0x88));
+ BtnRecord.ToolTip = "Aufnahme starten";
+ // Source-Badge wiederherstellen
+ if (_currentChannel != null)
+ {
+ TxtChannelSource.Text = _currentChannel.Source == ChannelSource.Online
+ ? "● Online" : "● FritzBox";
+ TxtChannelSource.Foreground = _currentChannel.Source == ChannelSource.Online
+ ? new System.Windows.Media.SolidColorBrush(
+ System.Windows.Media.Color.FromRgb(0x00, 0x78, 0xD4))
+ : new System.Windows.Media.SolidColorBrush(
+ System.Windows.Media.Color.FromRgb(0x66, 0xBB, 0x6A));
+ }
+ }
+ }
+
private void ToggleFullscreen()
{
if (!_isFullscreen)
diff --git a/Services/AppSettings.cs b/Services/AppSettings.cs
index 87fd4c8..19e5a59 100644
--- a/Services/AppSettings.cs
+++ b/Services/AppSettings.cs
@@ -16,6 +16,10 @@ public class AppSettings
/// Startkategorie beim App-Start (default: Favoriten)
public string StartCategory { get; set; } = "fav";
+ /// Ordner fuer Aufnahmen (default: Videos\HomeStream)
+ public string RecordingPath { get; set; } = System.IO.Path.Combine(
+ Environment.GetFolderPath(Environment.SpecialFolder.MyVideos), "HomeStream");
+
private static readonly string ConfigPath = AppPaths.Settings;
public static AppSettings Load()