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); }
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); 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); }
/// <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); }
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); }
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(Interop.Core.Events.EventTypes.MediaMetaChanged, onMetaChanged, IntPtr.Zero); EventManager.Attach(Interop.Core.Events.EventTypes.MediaSubItemAdded, onSubItemAdded, IntPtr.Zero); EventManager.Attach(Interop.Core.Events.EventTypes.MediaDurationChanged, onDurationChanged, IntPtr.Zero); EventManager.Attach(Interop.Core.Events.EventTypes.MediaParsedChanged, onParsedChanged, IntPtr.Zero); EventManager.Attach(Interop.Core.Events.EventTypes.MediaFreed, onFreed, IntPtr.Zero); EventManager.Attach(Interop.Core.Events.EventTypes.MediaStateChanged, onStateChanged, IntPtr.Zero); }
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); }