Example #1
0
        protected void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            HandleManager.Remove(this);

            _releaseInstanceFunction.Delegate(InstancePointer);

            InstancePointer = IntPtr.Zero;

            _onVlmMediaAddedHandle.Free();
            _onVlmMediaRemovedHandle.Free();
            _onVlmMediaChangedHandle.Free();
            _onVlmMediaInstanceStartedHandle.Free();
            _onVlmMediaInstanceStoppedHandle.Free();
            _onVlmMediaInstanceStatusInitHandle.Free();
            _onVlmMediaInstanceStatusOpeningHandle.Free();
            _onVlmMediaInstanceStatusPlayingHandle.Free();
            _onVlmMediaInstanceStatusPauseHandle.Free();
            _onVlmMediaInstanceStatusEndHandle.Free();
            _onVlmMediaInstanceStatusErrorHandle.Free();

            _disposed = true;
        }
Example #2
0
 /// <summary>
 ///     Release this event manager.
 /// </summary>
 /// <exception cref="Exception">A delegate callback throws an exception.</exception>
 public void Dispose()
 {
     HandleManager.Remove(this);
     // We should not free libvlc_event_manager instances as their life cycles are
     // managed by their parent libvlc_media_player or libvlc_media instances.
     InstancePointer = IntPtr.Zero;
 }
Example #3
0
        private VlcMedia(IVlcObject parentVlcObject, IntPtr pointer)
        {
            VlcInstance     = parentVlcObject.VlcInstance;
            InstancePointer = pointer;
            EventManager    = new VlcEventManager(this, _getEventManagerFunction.Delegate(InstancePointer));

            _onMetaChanged     = OnMetaChanged;
            _onSubItemAdded    = OnSubItemAdded;
            _onDurationChanged = OnDurationChanged;
            _onParsedChanged   = OnParsedChanged;
            _onFreed           = OnFreed;
            _onStateChanged    = OnStateChanged;

            _onMetaChangedHandle     = GCHandle.Alloc(_onMetaChanged);
            _onSubItemAddedHandle    = GCHandle.Alloc(_onSubItemAdded);
            _onDurationChangedHandle = GCHandle.Alloc(_onDurationChanged);
            _onParsedChangedHandle   = GCHandle.Alloc(_onParsedChanged);
            _onFreedHandle           = GCHandle.Alloc(_onFreed);
            _onStateChangedHandle    = GCHandle.Alloc(_onStateChanged);

            HandleManager.Add(this);

            EventManager.Attach(EventTypes.MediaMetaChanged, _onMetaChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaSubItemAdded, _onSubItemAdded, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaDurationChanged, _onDurationChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaParsedChanged, _onParsedChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaFreed, _onFreed, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaStateChanged, _onStateChanged, IntPtr.Zero);
        }
Example #4
0
        protected void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            HandleManager.Remove(this);

            EventManager.Detach(EventTypes.MediaMetaChanged, _onMetaChanged, IntPtr.Zero);
            EventManager.Detach(EventTypes.MediaSubItemAdded, _onSubItemAdded, IntPtr.Zero);
            EventManager.Detach(EventTypes.MediaDurationChanged, _onDurationChanged, IntPtr.Zero);
            EventManager.Detach(EventTypes.MediaParsedChanged, _onParsedChanged, IntPtr.Zero);
            EventManager.Detach(EventTypes.MediaFreed, _onFreed, IntPtr.Zero);
            EventManager.Detach(EventTypes.MediaStateChanged, _onStateChanged, IntPtr.Zero);

            EventManager.Dispose();
            _onMetaChangedHandle.Free();
            _onSubItemAddedHandle.Free();
            _onDurationChangedHandle.Free();
            _onParsedChangedHandle.Free();
            _onFreedHandle.Free();
            _onStateChangedHandle.Free();
            _releaseMediaFunction.Delegate(InstancePointer);
            InstancePointer = IntPtr.Zero;

            _disposed = true;
        }
Example #5
0
        public Vlc(String[] argv)
        {
            InstancePointer = argv == null
                ? _newInstanceFunction.Delegate(0, IntPtr.Zero)
                : _newInstanceFunction.Delegate(argv.Length, InteropHelper.StringArrayToPtr(argv));

            if (InstancePointer == IntPtr.Zero)
            {
                var ex = VlcError.GetErrorMessage();
                throw new VlcCreateFailException(ex);
            }

            EventManager = new VlcEventManager(this, _getMediaEventManagerFunction.Delegate(InstancePointer));

            _onVlmMediaAdded                 = OnVlmMediaAdded;
            _onVlmMediaRemoved               = OnVlmMediaRemoved;
            _onVlmMediaChanged               = OnVlmMediaChanged;
            _onVlmMediaInstanceStarted       = OnVlmMediaInstanceStarted;
            _onVlmMediaInstanceStopped       = OnVlmMediaInstanceStopped;
            _onVlmMediaInstanceStatusInit    = OnVlmMediaInstanceStatusInit;
            _onVlmMediaInstanceStatusOpening = OnVlmMediaInstanceStatusOpening;
            _onVlmMediaInstanceStatusPlaying = OnVlmMediaInstanceStatusPlaying;
            _onVlmMediaInstanceStatusPause   = OnVlmMediaInstanceStatusPause;
            _onVlmMediaInstanceStatusEnd     = OnVlmMediaInstanceStatusEnd;
            _onVlmMediaInstanceStatusError   = OnVlmMediaInstanceStatusError;

            _onVlmMediaAddedHandle                 = GCHandle.Alloc(_onVlmMediaAdded);
            _onVlmMediaRemovedHandle               = GCHandle.Alloc(_onVlmMediaRemoved);
            _onVlmMediaChangedHandle               = GCHandle.Alloc(_onVlmMediaChanged);
            _onVlmMediaInstanceStartedHandle       = GCHandle.Alloc(_onVlmMediaInstanceStarted);
            _onVlmMediaInstanceStoppedHandle       = GCHandle.Alloc(_onVlmMediaInstanceStopped);
            _onVlmMediaInstanceStatusInitHandle    = GCHandle.Alloc(_onVlmMediaInstanceStatusInit);
            _onVlmMediaInstanceStatusOpeningHandle = GCHandle.Alloc(_onVlmMediaInstanceStatusOpening);
            _onVlmMediaInstanceStatusPlayingHandle = GCHandle.Alloc(_onVlmMediaInstanceStatusPlaying);
            _onVlmMediaInstanceStatusPauseHandle   = GCHandle.Alloc(_onVlmMediaInstanceStatusPause);
            _onVlmMediaInstanceStatusEndHandle     = GCHandle.Alloc(_onVlmMediaInstanceStatusEnd);
            _onVlmMediaInstanceStatusErrorHandle   = GCHandle.Alloc(_onVlmMediaInstanceStatusError);

            HandleManager.Add(this);

            EventManager.Attach(EventTypes.VlmMediaAdded, _onVlmMediaAdded, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaRemoved, _onVlmMediaRemoved, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaChanged, _onVlmMediaChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaInstanceStarted, _onVlmMediaInstanceStarted, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaInstanceStopped, _onVlmMediaInstanceStopped, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaInstanceStatusInit, _onVlmMediaInstanceStatusInit, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaInstanceStatusOpening, _onVlmMediaInstanceStatusOpening, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaInstanceStatusPlaying, _onVlmMediaInstanceStatusPlaying, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaInstanceStatusPause, _onVlmMediaInstanceStatusPause, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaInstanceStatusEnd, _onVlmMediaInstanceStatusEnd, IntPtr.Zero);
            EventManager.Attach(EventTypes.VlmMediaInstanceStatusError, _onVlmMediaInstanceStatusError, IntPtr.Zero);
        }
Example #6
0
        protected void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            HandleManager.Remove(this);

            _releaseEqualizerFunction.Delegate(InstancePointer);

            InstancePointer = IntPtr.Zero;

            _disposed = true;
        }
Example #7
0
 /// <summary>
 ///     Create a new equalizer, with initial frequency values copied from an existing preset.
 /// </summary>
 /// <param name="index"></param>
 public AudioEqualizer(uint index)
 {
     InstancePointer = _createEqualizerFromPresetFunction.Delegate(index);
     HandleManager.Add(this);
 }
Example #8
0
 /// <summary>
 ///     Create a new default equalizer, with all frequency values zeroed.
 /// </summary>
 public AudioEqualizer()
 {
     InstancePointer = _createEqualizerFunction.Delegate();
     HandleManager.Add(this);
 }
Example #9
0
 /// <summary>
 ///     Create a event manager with parent Vlc object and pointer of event manager.
 /// </summary>
 /// <param name="parentVlcObject"></param>
 /// <param name="pointer"></param>
 public VlcEventManager(IVlcObject parentVlcObject, IntPtr pointer)
 {
     VlcInstance     = parentVlcObject.VlcInstance;
     InstancePointer = pointer;
     HandleManager.Add(this);
 }