I using the UWP project (target 1903, min 1809). Installed nugets: VideoLAN.LibVLC.UWP (3.3.0) LibVLCSharp (3.4.8)
Goal: I trying to record video N minutes duration using RTSP when I use mediaPlayer.Stop() or mediaPlayer.Dispose(), then getting the error "An unhandled win32 exception occurred in..." Construction try..catch doesn't catch.
If I use like below, I don't have exception, but not all files recorded. What I mean, for example:
10 files created. But only 8 files recorded, when I closed the app. If the app is open, then not visible what files are being recorded.
mediaPlayer = null;
mediaPlayer?.Dispose();
LibVLC = null;
LibVLC?.Dispose();
Full example:
while(true)
{
var name = $"{DateTime.Now.ToString("HH\\:mm\\:ss").Replace(":", ".")}.ts";
var storageFileVideo = await storageFolderDate.CreateFileAsync(name);
var LibVLC = new LibVLC();
var mediaPlayer = new MediaPlayer(LibVLC);
using (var media = new Media(LibVLC, new Uri("RTSP address")))
{
media.AddOption($":sout=#file{{dst={storageFileVideo.Path}}}");
media.AddOption(":sout-keep");
mediaPlayer.Play(media);
// await Task.Delay(5000);
//mediaPlayer = null;
//mediaPlayer?.Dispose();
//LibVLC = null;
//LibVLC?.Dispose();
}
}
I also tried like below:
ThreadPool.QueueUserWorkItem(_ => { /*play and stop or dispose*/ });
How I can resolve it? Thank you.
Problem solved. Bug has been fixed in version VideoLAN.LibVLC.UWP 3.3.1