我正在使用 WPF VLC lib 播放视频,但应用程序突然崩溃而没有抛出任何异常。我在事件查看器 > Windows 日志 > 应用程序中发现了一些错误。
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:
这是实现
为......而玩:
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();
处置:
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);
}
});
处理对象时会发生这种情况(当视频完成并尝试开始新的视频时)。
请让我知道我在这里做错了什么。
任何帮助,将不胜感激。提前致谢。