Stop record video
Hello, I using UWP project (target 1903, min 1809). Installed nugets: VideoLAN.LibVLC.UWP (3.3.0) LibVLCSharp (3.4.8)
Goal: I trying record video N minutes duration using RTSP, when I use mediaPlayer.Stop() or mediaPlayer.Dispose(), then getting error "An unhandled win32 exception occured 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, example:
10 files created. But only 8 files recorded, when i closed app. If 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.