//========================================================================== private void Dispose(bool disposing) { if (m_MediaPlayerHandle != IntPtr.Zero) { m_Library.libvlc_media_player_release(m_MediaPlayerHandle); if (disposing) { UnregisterMediaPlayer(m_MediaPlayerHandle); } m_MediaPlayerHandle = IntPtr.Zero; } if (disposing) { if (m_Instance != null) { if (m_IsInstanceOwner) { m_Instance.Dispose(); } m_Instance = null; } if (m_Library != null) { if (m_IsLibraryOwner) { LibVLCLibrary.Free(m_Library); } m_Library = null; } } }
//========================================================================== private void Dispose(bool disposing) { if (m_Handle != IntPtr.Zero) { m_Library.libvlc_release(m_Handle); m_Handle = IntPtr.Zero; } if (disposing) { if (m_Library != null) { if (m_IsLibraryOwner) { LibVLCLibrary.Free(m_Library); } m_Library = null; } } }
//========================================================================== /// <summary> /// Initializes a new instance of the class <see cref="Instance"/>. /// </summary> /// <param name="library"> /// May be <c>null</c> to use the default library. /// </param> public Instance(LibVLCLibrary library) { if (library == null) { m_Library = LibVLCLibrary.Load(null); m_IsLibraryOwner = true; } else { m_Library = library; m_IsLibraryOwner = false; } try { m_Handle = m_Library.libvlc_new(false);//Not Environment Path if (m_Handle == IntPtr.Zero) { throw new LibVLCException(m_Library); } } catch { if (m_IsLibraryOwner) { try { LibVLCLibrary.Free(m_Library); } catch { // ... } } throw; } }
//========================================================================== public MediaPlayer(LibVLCLibrary library, Instance instance) { if (library != null) { if (instance != null) { if (instance.Library != library) { throw new ArgumentException("The provided instance has not been created with the provided library!", "instance"); } } } if (instance != null) { if (library == null) { library = instance.Library; } } if (library == null) { m_Library = LibVLCLibrary.Load(null); m_IsLibraryOwner = true; } else { m_Library = library; m_IsLibraryOwner = false; } try { if (instance == null) { m_Instance = new Instance(m_Library); m_IsInstanceOwner = true; } else { m_Instance = instance; m_IsInstanceOwner = false; } try { m_MediaPlayerHandle = CreateHandle(); m_oldMediaPlayerHandle = m_MediaPlayerHandle;//Park MediaPlayer } catch { if (m_IsInstanceOwner) { m_Instance.Dispose(); } m_Instance = null; throw; } } catch { if (m_IsLibraryOwner) { LibVLCLibrary.Free(m_Library); } m_Library = null; throw; } }