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); }
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; }
protected void Dispose(bool disposing) { if (disposed) { return; } HandleManager.Remove(this); //EventManager.Dispose(); onPlayingHandle.Free(); onPausedHandle.Free(); onOpeningHandle.Free(); onBufferingHandle.Free(); onStopedHandle.Free(); onForwardHandle.Free(); onBackwardHandle.Free(); onEndReachedHandle.Free(); onMediaChangedHandle.Free(); onNothingSpecialHandle.Free(); onPausableChangedHandle.Free(); onPositionChangedHandle.Free(); onSeekableChangedHandle.Free(); onSnapshotTakenHandle.Free(); onTimeChangedHandle.Free(); onTitleChangedHandle.Free(); onVideoOutChangedHandle.Free(); onLengthChangedHandle.Free(); onEncounteredErrorHandle.Free(); ReleaseMediaPlayerFunction.Delegate(InstancePointer); InstancePointer = IntPtr.Zero; disposed = true; }
void OnMediaChanged(ref LibVlcEventArgs eventArgs, IntPtr userData) { if (MediaChanged != null) { MediaChanged(this, new MediaPlayerMediaChangedEventArgs(HandleManager.GetVlcObject(eventArgs.MediaPlayerMediaChanged.NewMediaHandle) as VlcMedia)); } }
protected void Dispose(bool disposing) { if (_disposed) { return; } //EventManager.Dispose(); HandleManager.Remove(this); EventManager.Detach(EventTypes.MediaPlayerPlaying, _onPlaying, IntPtr.Zero); EventManager.Detach(EventTypes.MediaPlayerPaused, _onPaused, IntPtr.Zero); EventManager.Detach(EventTypes.MediaPlayerOpening, _onOpening, IntPtr.Zero); EventManager.Detach(EventTypes.MediaPlayerBuffering, _onBuffering, IntPtr.Zero); EventManager.Detach(EventTypes.MediaPlayerStopped, _onStoped, IntPtr.Zero); EventManager.Detach(EventTypes.MediaPlayerForward, _onForward, IntPtr.Zero); EventManager.Detach(EventTypes.MediaPlayerBackward, _onBackward, IntPtr.Zero); EventManager.Detach(EventTypes.MediaPlayerEndReached, _onEndReached, IntPtr.Zero); EventManager.Detach(EventTypes.MediaPlayerMediaChanged, _onMediaChanged, IntPtr.Zero); EventManager.Detach(EventTypes.MediaPlayerNothingSpecial, _onNothingSpecial, IntPtr.Zero); EventManager.Detach(EventTypes.MediaPlayerPausableChanged, _onPausableChanged, IntPtr.Zero); EventManager.Detach(EventTypes.MediaPlayerPositionChanged, _onPositionChanged, IntPtr.Zero); EventManager.Detach(EventTypes.MediaPlayerSeekableChanged, _onSeekableChanged, IntPtr.Zero); EventManager.Detach(EventTypes.MediaPlayerSnapshotTaken, _onSnapshotTaken, IntPtr.Zero); EventManager.Detach(EventTypes.MediaPlayerTimeChanged, _onTimeChanged, IntPtr.Zero); EventManager.Detach(EventTypes.MediaPlayerTitleChanged, _onTitleChanged, IntPtr.Zero); EventManager.Detach(EventTypes.MediaPlayerVideoOutChanged, _onVideoOutChanged, IntPtr.Zero); EventManager.Detach(EventTypes.MediaPlayerLengthChanged, _onLengthChanged, IntPtr.Zero); EventManager.Detach(EventTypes.MediaPlayerEncounteredError, _onEncounteredError, IntPtr.Zero); _onPlayingHandle.Free(); _onPausedHandle.Free(); _onOpeningHandle.Free(); _onBufferingHandle.Free(); _onStopedHandle.Free(); _onForwardHandle.Free(); _onBackwardHandle.Free(); _onEndReachedHandle.Free(); _onMediaChangedHandle.Free(); _onNothingSpecialHandle.Free(); _onPausableChangedHandle.Free(); _onPositionChangedHandle.Free(); _onSeekableChangedHandle.Free(); _onSnapshotTakenHandle.Free(); _onTimeChangedHandle.Free(); _onTitleChangedHandle.Free(); _onVideoOutChangedHandle.Free(); _onLengthChangedHandle.Free(); _onEncounteredErrorHandle.Free(); _releaseMediaPlayerFunction.Delegate(InstancePointer); InstancePointer = IntPtr.Zero; _disposed = true; }
/// <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); }
protected void Dispose(bool disposing) { if (disposed) { return; } HandleManager.Remove(this); ReleaseInstanceFunction.Delegate(InstancePointer); InstancePointer = IntPtr.Zero; disposed = true; }
/// <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); }
protected void Dispose(bool disposing) { if (_disposed) { return; } HandleManager.Remove(this); EventManager.Dispose(); _onMetaChangedHandle.Free(); _onSubItemAddedHandle.Free(); _onDurationChangedHandle.Free(); _onParsedChangedHandle.Free(); _onFreedHandle.Free(); _onStateChangedHandle.Free(); _releaseMediaFunction.Delegate(InstancePointer); InstancePointer = IntPtr.Zero; _disposed = true; }
/// <summary> /// Create a new default equalizer, with all frequency values zeroed. /// </summary> public AudioEqualizer() { InstancePointer = _createEqualizerFunction.Delegate(); HandleManager.Add(this); }
/// <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); }
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); }
public void Dispose() { HandleManager.Remove(this); Vlc.Free(InstancePointer); InstancePointer = IntPtr.Zero; }
public VlcEventManager(IntPtr pointer) { InstancePointer = pointer; HandleManager.Add(this); }
/// <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); }
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); }