//========================================================================== /// <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(); 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(); } catch { if (m_IsInstanceOwner) { m_Instance.Dispose(); } m_Instance = null; throw; } } catch { if (m_IsLibraryOwner) { LibVLCLibrary.Free(m_Library); } m_Library = null; throw; } }