Aufnahme: Start/Stop Button, libVLC sout in Videos\HomeStream, REC-Badge
This commit is contained in:
parent
b9b5d1c923
commit
b0e9e1022f
3 changed files with 95 additions and 0 deletions
|
|
@ -381,6 +381,9 @@
|
|||
<Slider x:Name="SldVolume" Width="100" Minimum="0" Maximum="100" Value="80"
|
||||
VerticalAlignment="Center" Margin="8,0"
|
||||
ValueChanged="SldVolume_ValueChanged"/>
|
||||
<Button x:Name="BtnRecord" Content="⏺" FontSize="16" Width="40" Height="40"
|
||||
Background="Transparent" Foreground="#888" BorderThickness="0"
|
||||
Click="BtnRecord_Click" Cursor="Hand" ToolTip="Aufnahme starten"/>
|
||||
<Button x:Name="BtnFullscreen" Content="⛶" FontSize="16" Width="40" Height="40"
|
||||
Background="Transparent" Foreground="White" BorderThickness="0"
|
||||
Click="BtnFullscreen_Click" Cursor="Hand" ToolTip="Vollbild (F11)"/>
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@ public class AppSettings
|
|||
/// <summary>Startkategorie beim App-Start (default: Favoriten)</summary>
|
||||
public string StartCategory { get; set; } = "fav";
|
||||
|
||||
/// <summary>Ordner fuer Aufnahmen (default: Videos\HomeStream)</summary>
|
||||
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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue