/// <summary> /// Attaches an event to player with selected eventManager. /// And stores used delegate in internal list. /// </summary> internal void attachToEvent(IntPtr eventManager, Delegate eventHandlerDelegate, libvlc_event_type_e eventType, Object tag) { if (eventManager == IntPtr.Zero) { throw new ArgumentException("IntPtr.Zero is invalid value.", "eventManager"); } if (eventHandlerDelegate == null) { throw new ArgumentNullException("eventHandlerDelegate"); } // AttachedEvent newEvent = new AttachedEvent(); { newEvent.EventManager = eventManager; newEvent.EventType = eventType; newEvent.UserData = new IntPtr(totalEventsAttached++); newEvent.Event = eventHandlerDelegate; newEvent.Function = Marshal.GetFunctionPointerForDelegate(eventHandlerDelegate); newEvent.Tag = tag; }; // int res = LibVlcInterop.libvlc_event_attach(newEvent.EventManager, newEvent.EventType, newEvent.Function, newEvent.UserData); if (res != 0) { throw new VlcInternalException(String.Format("Unable to attach event {0}", eventType.ToString())); } // save delegate to a private list (to suppress finalizing it) eventDelegates.Add(newEvent); }
/// <summary> /// Attaches an event to player with selected eventManager. /// And stores used delegate in internal list. /// </summary> internal void attachToEvent(IntPtr eventManager, Delegate eventHandlerDelegate, libvlc_event_type_e eventType) { attachToEvent(eventManager, eventHandlerDelegate, eventType, null); }