64a337ffe8
- 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
48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using LibVLCSharp.Shared;
|
|
|
|
namespace TV_Player
|
|
{
|
|
public static class LibVLCManager
|
|
{
|
|
private static readonly object _lock = new object();
|
|
private static LibVLC _instance;
|
|
|
|
public static LibVLC Instance
|
|
{
|
|
get
|
|
{
|
|
if (_instance != null) return _instance;
|
|
lock (_lock)
|
|
{
|
|
if (_instance == null)
|
|
{
|
|
Core.Initialize();
|
|
// Use conservative libvlc options to reduce native crashes
|
|
var options = new[]
|
|
{
|
|
"--ignore-config",
|
|
"--no-osd",
|
|
"--no-snapshot-preview",
|
|
"--avcodec-hw=none",
|
|
"--network-caching=3000",
|
|
"--http-reconnect",
|
|
"--rtsp-tcp"
|
|
};
|
|
_instance = new LibVLC(options);
|
|
}
|
|
return _instance;
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void Dispose()
|
|
{
|
|
lock (_lock)
|
|
{
|
|
try { _instance?.Dispose(); } catch { }
|
|
_instance = null;
|
|
}
|
|
}
|
|
}
|
|
}
|