Files
vova 64a337ffe8 Improve LibVLC stability and add external playback host
- Add LibVLCManager singleton for safer LibVLC lifetime management
- Introduce VlcHostClient and VlcHost.exe for external playback via JSON commands
- Enhance VideoPlayer with error recovery and dependency property for SourceUrl
- Implement IDisposable in ProgramsData and ViewModels for better cleanup
- Update NuGet packages: LibVLCSharp to 3.9.6, System.Reactive to 6.1.0
- Add robust error handling and resource disposal throughout
- Improve program guide handling in PlayerViewModel
2026-04-10 14:29:00 +03:00

47 lines
1.3 KiB
C#

using System.Windows;
using TV_Player.ViewModels;
namespace TV_Player
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
private TVPlayerViewModel _tvPlayer;
private const string Guid = "ac8ab758-01e2-47c3-ad42-31e96d8203c0";
static readonly Mutex Mutex = new Mutex(true, "{" + Guid + "}");
protected override void OnStartup(StartupEventArgs e)
{
AppDomain.CurrentDomain.UnhandledException += ReportAndRestart;
if (!Mutex.WaitOne(TimeSpan.Zero, true))
{
MessageBox.Show("Programm already running");
Current.Shutdown();
}
_tvPlayer = new TVPlayerViewModel();
base.OnStartup(e);
}
protected void ReportAndRestart(object sender, UnhandledExceptionEventArgs e)
{
string info = e.ExceptionObject.ToString();
var result=MessageBox.Show(info, "Application", MessageBoxButton.OK, MessageBoxImage.Stop);
//Environment.Exit(1);
}
protected override void OnExit(ExitEventArgs e)
{
_tvPlayer.Dispose();
// dispose shared LibVLC instance
try { LibVLCManager.Dispose(); } catch { }
base.OnExit(e);
}
}
}