/// <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, void *pointer) { VlcInstance = parentVlcObject.VlcInstance; InstancePointer = pointer; VlcObjectManager.Add(this); _onVlcEventFired = OnVlcEventFired; _onVlcEventFiredHandle = GCHandle.Alloc(_onVlcEventFired); }
protected void Dispose(bool disposing) { if (_disposed) { return; } _onExitHandle.Free(); VlcObjectManager.Remove(this); LibVlcManager.GetFunctionDelegate <libvlc_release>().Invoke(InstancePointer); InstancePointer = null; _disposed = true; }
/// <summary> /// Create a Vlc instance by options. /// </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 ? LibVlcManager.GetFunctionDelegate <libvlc_new>().Invoke(0, IntPtr.Zero) : LibVlcManager.GetFunctionDelegate <libvlc_new>() .Invoke(argv.Length, InteropHelper.StringArrayToPtr(argv)); if (InstancePointer == null) { throw new VlcCreateFailException(VlcError.GetErrorMessage()); } ExitHandler onExit = OnExit; _onExitHandle = GCHandle.Alloc(onExit); LibVlcManager.GetFunctionDelegate <libvlc_set_exit_handler>().Invoke(InstancePointer, onExit, null); VlcObjectManager.Add(this); }
private VlcMedia(IVlcObject parentVlcObject, void *pointer) { VlcInstance = parentVlcObject.VlcInstance; InstancePointer = pointer; VlcObjectManager.Add(this); EventManager = new VlcEventManager(this, LibVlcManager.GetFunctionDelegate <libvlc_media_event_manager>().Invoke(InstancePointer)); EventManager.Attach(EventType.MediaMetaChanged); EventManager.Attach(EventType.MediaSubItemAdded); EventManager.Attach(EventType.MediaDurationChanged); EventManager.Attach(EventType.MediaParsedChanged); EventManager.Attach(EventType.MediaFreed); EventManager.Attach(EventType.MediaStateChanged); EventManager.Attach(EventType.MediaSubItemTreeAdded); EventManager.VlcEventFired += OnVlcEventFired; }
private VlcMediaPlayer(IVlcObject parentVlcObject, void* pointer) { VlcInstance = parentVlcObject.VlcInstance; InstancePointer = pointer; VlcObjectManager.Add(this); EventManager = new VlcEventManager(this, LibVlcManager.GetFunctionDelegate<libvlc_media_player_event_manager>().Invoke(InstancePointer)); EventManager.Attach(EventType.MediaPlayerPlaying); EventManager.Attach(EventType.MediaPlayerPaused); EventManager.Attach(EventType.MediaPlayerOpening); EventManager.Attach(EventType.MediaPlayerBuffering); EventManager.Attach(EventType.MediaPlayerStopped); EventManager.Attach(EventType.MediaPlayerForward); EventManager.Attach(EventType.MediaPlayerBackward); EventManager.Attach(EventType.MediaPlayerEndReached); EventManager.Attach(EventType.MediaPlayerMediaChanged); EventManager.Attach(EventType.MediaPlayerNothingSpecial); EventManager.Attach(EventType.MediaPlayerPausableChanged); EventManager.Attach(EventType.MediaPlayerPositionChanged); EventManager.Attach(EventType.MediaPlayerSeekableChanged); EventManager.Attach(EventType.MediaPlayerSnapshotTaken); EventManager.Attach(EventType.MediaPlayerTimeChanged); EventManager.Attach(EventType.MediaPlayerTitleChanged); EventManager.Attach(EventType.MediaPlayerLengthChanged); EventManager.Attach(EventType.MediaPlayerEncounteredError); EventManager.Attach(EventType.MediaPlayerVout); EventManager.Attach(EventType.MediaPlayerScrambledChanged); EventManager.Attach(EventType.MediaPlayerESAdded); EventManager.Attach(EventType.MediaPlayerESDeleted); EventManager.Attach(EventType.MediaPlayerESSelected); EventManager.Attach(EventType.MediaPlayerCorked); EventManager.Attach(EventType.MediaPlayerUncorked); EventManager.Attach(EventType.MediaPlayerMuted); EventManager.Attach(EventType.MediaPlayerUnmuted); EventManager.Attach(EventType.MediaPlayerAudioVolume); EventManager.Attach(EventType.MediaPlayerAudioDevice); EventManager.Attach(EventType.MediaPlayerChapterChanged); EventManager.VlcEventFired += OnVlcEventFired; }