0

I am using WPF VLC lib for playing video but app abruptly crashed without throwing any exception. I have found some error in event Viewer > Windows log > application.

Fault bucket 1600891151472079635, type 1
Event Name: APPCRASH
Response: Not available
Cab Id: 0

Problem signature:
P1: OMNIplay.exe
P2: 1.0.0.11
P3: 8d524c28
P4: libdcp_plugin.dll
P5: 3.0.16.0
P6: 3a493a41
P7: 40000015
P8: 000fbf77
P9: 
P10: 

Here is the implementation

For play:

private VlcControl _mediaVLCPlayerElement;
private VlcMediaPlayer _vlcMediaPlayer;

var currentAssembly = Assembly.GetEntryAssembly();

var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
var vlcLibDirectory = new DirectoryInfo(System.IO.Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));

var options = new string[]
                {
                    // VLC options can be given here. Please refer to the VLC command line documentation.
                    "avcodec-hw=any"
                };

_mediaVLCPlayerElement = new VlcControl();
Trace.WriteLine("Creating player begins");

_mediaVLCPlayerElement.SourceProvider.CreatePlayer(vlcLibDirectory, options);
Trace.WriteLine("Player Created");

_vlcMediaPlayer = _mediaVLCPlayerElement.SourceProvider.MediaPlayer;
_vlcMediaPlayer.Log += OnLog;
_vlcMediaPlayer.Video.FullScreen = true;
_vlcMediaPlayer.EndReached += OnMediaEnded;
_vlcMediaPlayer.EncounteredError += OnMediaFailed;
_vlcMediaPlayer.Opening += OnMediaOpening;
_vlcMediaPlayer.SetMedia(new Uri(url, UriKind.Absolute), options);
_vlcMediaPlayer.play();

For disposing:

ThreadPool.QueueUserWorkItem(_ => {
                    try
                    {
                        _vlcMediaPlayer.EndReached -= OnMediaEnded;
                        _vlcMediaPlayer.EncounteredError -= OnMediaFailed;
                        _vlcMediaPlayer.Opening -= OnMediaOpening;
                        _vlcMediaPlayer.Log -= OnLog;
                        _vlcMediaPlayer.Stop();
                        _vlcMediaPlayer.GetMedia().Dispose();
                        _vlcMediaPlayer.Dispose();

                        if (_mediaVLCPlayerElement != null)
                        {
                            Trace.WriteLine("Player disposing...");
                            _mediaVLCPlayerElement.SourceProvider.Dispose();
                            _mediaVLCPlayerElement.Dispose();
                            _mediaVLCPlayerElement = null;
                            Trace.WriteLine("Player disposed...");
                        }

                      _vlcMediaPlayer = null;
                    }
                    catch (Exception e)
                    {
                        Trace.WriteLine("Release VLC object: " + e.Message);
                    }
                });

This is happening when disposing the object (when video is completed and trying to start new one).

Please let me know what wrong I am doing here.

Any help would be appreciated. Thanks in advance.

mfkl
  • 1,914
  • 1
  • 11
  • 21
mani gupta
  • 109
  • 1
  • 13
  • Just for information:- I am using following versions:- VideoLAN.LibVLC.Windows version is 3.0.16 Vlc.DotNet.Core version is 3.1.0 Vlc.DotNet.Core.Interops version is 3.1.0 Vlc.DotNet.Wpf version is 3.1.0 – mani gupta Jan 07 '22 at 05:21
  • 1
    Does VLC crash the same way with the same stream? it definitely sounds like a VLC crash instead of a Vlc.DotNet issue – cube45 Jan 08 '22 at 10:55
  • 1
    You didn't even say what kind of media it is. When asking questions, always send full logs. Please also try with other kind of files – cube45 Jan 08 '22 at 10:57
  • No, VLC does not get crashed while playing same media, I am playing .mp4 file from local. One more thing is that media has short duration like 6sec, 9 sec, playing in loop. – mani gupta Jan 08 '22 at 17:20
  • I handled most of the exception but when app crashes, no exception and log there, just being crashed. I have suspect there is native reference or object of vlc lib which do not exist in c# memory not being cleared as result, process heap, stack memory are fulled and app crashed. – mani gupta Jan 08 '22 at 17:26
  • You should enable verbose logs, that gives you an hint. See the wiki for info on how to do that. However, we will be unable to help without a way to reproduce the issue. First try with VLC.exe and see if it crashes too – cube45 Jan 08 '22 at 21:15

0 Answers0