diff --git a/src/LibVLCSharp.WinForms/VideoView.cs b/src/LibVLCSharp.WinForms/VideoView.cs index 3fbb48bf31f9176c05beca0501d2b054c17b8639..f7e9061544c87c415fccb9fd8f8296a884d851ff 100644 --- a/src/LibVLCSharp.WinForms/VideoView.cs +++ b/src/LibVLCSharp.WinForms/VideoView.cs @@ -77,7 +77,7 @@ namespace LibVLCSharp.WinForms void Detach() { - if (_mp == null) + if (_mp == null || _mp.NativeReference == IntPtr.Zero) return; _mp.Hwnd = IntPtr.Zero; @@ -85,7 +85,7 @@ namespace LibVLCSharp.WinForms void Attach() { - if (_mp == null) + if (_mp == null || _mp.NativeReference == IntPtr.Zero) return; _mp.Hwnd = Handle; @@ -103,14 +103,13 @@ namespace LibVLCSharp.WinForms { if (disposing) { - if (MediaPlayer != null) + if (MediaPlayer != null && MediaPlayer.NativeReference != IntPtr.Zero) { MediaPlayer.Hwnd = IntPtr.Zero; } } - disposedValue = true; } - } + } } }