Пример #1
0
        private VlcMedia(IntPtr pointer)
        {
            InstancePointer = pointer;
            EventManager    = new VlcEventManager(_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
        /// <summary>
        ///     提供指定的参数初始化一个 Vlc 实例
        /// </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>
        /// 提供指定的参数初始化一个 Vlc 实例
        /// </summary>
        /// <param name="argv"></param>
        public Vlc(String[] argv)
        {
            if (!IsLibLoaded)
            {
                LoadLibVlc();
            }

            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 Exception(ex);
            }

            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);
 }
Пример #6
0
        private VlcMediaPlayer(IntPtr pointer)
        {
            InstancePointer = pointer;
            EventManager    = new VlcEventManager(GetEventManagerFunction.Delegate(InstancePointer));

            HandleManager.Add(this);

            onPlaying          = OnPlaying;
            onPaused           = OnPaused;
            onOpening          = OnOpening;
            onBuffering        = OnBuffering;
            onStoped           = OnStoped; //This Event has something wrong.
            onForward          = OnForward;
            onBackward         = OnBackward;
            onEndReached       = OnEndReached;
            onMediaChanged     = OnMediaChanged;
            onNothingSpecial   = OnNothingSpecial;
            onPausableChanged  = OnPausableChanged;
            onPositionChanged  = OnPositionChanged;
            onSeekableChanged  = OnSeekableChanged;
            onSnapshotTaken    = OnSnapshotTaken;
            onTimeChanged      = OnTimeChanged;
            onTitleChanged     = OnTitleChanged;
            onVideoOutChanged  = OnVideoOutChanged;
            onLengthChanged    = OnLengthChanged;
            onEncounteredError = OnEncounteredError;

            onPlayingHandle          = GCHandle.Alloc(onPlaying);
            onPausedHandle           = GCHandle.Alloc(onPaused);
            onOpeningHandle          = GCHandle.Alloc(onOpening);
            onBufferingHandle        = GCHandle.Alloc(onBuffering);
            onStopedHandle           = GCHandle.Alloc(onStoped); //This Event has something wrong.
            onForwardHandle          = GCHandle.Alloc(onForward);
            onBackwardHandle         = GCHandle.Alloc(onBackward);
            onEndReachedHandle       = GCHandle.Alloc(onEndReached);
            onMediaChangedHandle     = GCHandle.Alloc(onMediaChanged);
            onNothingSpecialHandle   = GCHandle.Alloc(onNothingSpecial);
            onPausableChangedHandle  = GCHandle.Alloc(onPausableChanged);
            onPositionChangedHandle  = GCHandle.Alloc(onPositionChanged);
            onSeekableChangedHandle  = GCHandle.Alloc(onSeekableChanged);
            onSnapshotTakenHandle    = GCHandle.Alloc(onSnapshotTaken);
            onTimeChangedHandle      = GCHandle.Alloc(onTimeChanged);
            onTitleChangedHandle     = GCHandle.Alloc(onTitleChanged);
            onVideoOutChangedHandle  = GCHandle.Alloc(onVideoOutChanged);
            onLengthChangedHandle    = GCHandle.Alloc(onLengthChanged);
            onEncounteredErrorHandle = GCHandle.Alloc(onEncounteredError);

            EventManager.Attach(EventTypes.MediaPlayerPlaying, onPlaying, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerPaused, onPaused, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerOpening, onOpening, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerBuffering, onBuffering, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerStopped, onStoped, IntPtr.Zero);  //This Event has something wrong.
            EventManager.Attach(EventTypes.MediaPlayerForward, onForward, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerBackward, onBackward, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerEndReached, onEndReached, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerMediaChanged, onMediaChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerNothingSpecial, onNothingSpecial, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerPausableChanged, onPausableChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerPositionChanged, onPositionChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerSeekableChanged, onSeekableChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerSnapshotTaken, onSnapshotTaken, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerTimeChanged, onTimeChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerTitleChanged, onTitleChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerVideoOutChanged, onVideoOutChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerLengthChanged, onLengthChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerEncounteredError, onEncounteredError, IntPtr.Zero);
        }
Пример #7
0
 public VlcEventManager(IntPtr pointer)
 {
     InstancePointer = pointer;
     HandleManager.Add(this);
 }
Пример #8
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);
 }
Пример #9
0
        private VlcMediaPlayer(IVlcObject parentVlcObject, IntPtr pointer)
        {
            VlcInstance     = parentVlcObject.VlcInstance;
            InstancePointer = pointer;
            EventManager    = new VlcEventManager(this, _getEventManagerFunction.Delegate(InstancePointer));

            HandleManager.Add(this);

            _onPlaying          = OnPlaying;
            _onPaused           = OnPaused;
            _onOpening          = OnOpening;
            _onBuffering        = OnBuffering;
            _onStoped           = OnStoped;
            _onForward          = OnForward;
            _onBackward         = OnBackward;
            _onEndReached       = OnEndReached;
            _onMediaChanged     = OnMediaChanged;
            _onNothingSpecial   = OnNothingSpecial;
            _onPausableChanged  = OnPausableChanged;
            _onPositionChanged  = OnPositionChanged;
            _onSeekableChanged  = OnSeekableChanged;
            _onSnapshotTaken    = OnSnapshotTaken;
            _onTimeChanged      = OnTimeChanged;
            _onTitleChanged     = OnTitleChanged;
            _onVideoOutChanged  = OnVideoOutChanged;
            _onLengthChanged    = OnLengthChanged;
            _onEncounteredError = OnEncounteredError;

            _onPlayingHandle          = GCHandle.Alloc(_onPlaying);
            _onPausedHandle           = GCHandle.Alloc(_onPaused);
            _onOpeningHandle          = GCHandle.Alloc(_onOpening);
            _onBufferingHandle        = GCHandle.Alloc(_onBuffering);
            _onStopedHandle           = GCHandle.Alloc(_onStoped);
            _onForwardHandle          = GCHandle.Alloc(_onForward);
            _onBackwardHandle         = GCHandle.Alloc(_onBackward);
            _onEndReachedHandle       = GCHandle.Alloc(_onEndReached);
            _onMediaChangedHandle     = GCHandle.Alloc(_onMediaChanged);
            _onNothingSpecialHandle   = GCHandle.Alloc(_onNothingSpecial);
            _onPausableChangedHandle  = GCHandle.Alloc(_onPausableChanged);
            _onPositionChangedHandle  = GCHandle.Alloc(_onPositionChanged);
            _onSeekableChangedHandle  = GCHandle.Alloc(_onSeekableChanged);
            _onSnapshotTakenHandle    = GCHandle.Alloc(_onSnapshotTaken);
            _onTimeChangedHandle      = GCHandle.Alloc(_onTimeChanged);
            _onTitleChangedHandle     = GCHandle.Alloc(_onTitleChanged);
            _onVideoOutChangedHandle  = GCHandle.Alloc(_onVideoOutChanged);
            _onLengthChangedHandle    = GCHandle.Alloc(_onLengthChanged);
            _onEncounteredErrorHandle = GCHandle.Alloc(_onEncounteredError);

            EventManager.Attach(EventTypes.MediaPlayerPlaying, _onPlaying, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerPaused, _onPaused, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerOpening, _onOpening, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerBuffering, _onBuffering, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerStopped, _onStoped, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerForward, _onForward, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerBackward, _onBackward, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerEndReached, _onEndReached, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerMediaChanged, _onMediaChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerNothingSpecial, _onNothingSpecial, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerPausableChanged, _onPausableChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerPositionChanged, _onPositionChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerSeekableChanged, _onSeekableChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerSnapshotTaken, _onSnapshotTaken, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerTimeChanged, _onTimeChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerTitleChanged, _onTitleChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerVideoOutChanged, _onVideoOutChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerLengthChanged, _onLengthChanged, IntPtr.Zero);
            EventManager.Attach(EventTypes.MediaPlayerEncounteredError, _onEncounteredError, IntPtr.Zero);
        }