コード例 #1
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);
        }
コード例 #2
0
ファイル: Vlc.cs プロジェクト: phamvv/Meta.Vlc
        /// <summary>
        ///     Provide a specified parameter to initialize a Vlc instance
        /// </summary>
        /// <param name="argv"></param>
        /// <exception cref="VlcCreateFailException">Can't create a Vlc instence, check your Vlc options.</exception>
        /// <exception cref="Exception">A delegate callback throws an exception.</exception>
        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);
        }
コード例 #3
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);
 }
コード例 #4
0
 /// <summary>
 ///     Create a new default equalizer, with all frequency values zeroed.
 /// </summary>
 public AudioEqualizer()
 {
     InstancePointer = _createEqualizerFunction.Delegate();
     HandleManager.Add(this);
 }
コード例 #5
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);
 }