コード例 #1
0
ファイル: VlcPlayerBase.cs プロジェクト: uzbekdev1/libvlcnet
        /// <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);
        }
コード例 #2
0
ファイル: VlcPlayerBase.cs プロジェクト: uzbekdev1/libvlcnet
 internal void detachAllEventsWhereTag(Object tag)
 {
     for (int i = 0; i < eventDelegates.Count;)
     {
         AttachedEvent eventInfo = eventDelegates[i];
         if (eventInfo.Tag == tag)
         {
             detachEvent(eventInfo);
             eventDelegates.RemoveAt(i);
         }
         else
         {
             i++;
         }
     }
 }
コード例 #3
0
ファイル: VlcPlayerBase.cs プロジェクト: uzbekdev1/libvlcnet
 /// <summary>
 /// Detaches events attached previously.
 /// </summary>
 internal static void detachEvent(AttachedEvent eventAttached)
 {
     LibVlcInterop.libvlc_event_detach(eventAttached.EventManager, eventAttached.EventType,
                                       eventAttached.Function,
                                       eventAttached.UserData);
 }