internal VlcSinglePlayer(PlayerOutput playerOutput, IInternalObjectsFactory internalObjectsFactory) : base(internalObjectsFactory) { if (playerOutput == null) { throw new ArgumentNullException("playerOutput"); } if (playerOutput.Window != null && !(playerOutput.Window is DoubleWindowBase)) { //NOTE: it is not realy neccessary for VlcSinglePlayer - should we create simpler Window class? throw new ArgumentException("Window property of PlayerOutput should be of class DoubleWindowBase.", "playerOutput"); } if (internalObjectsFactory == null) { throw new ArgumentNullException("internalObjectsFactory"); } // this.playerOutput = playerOutput; this.internalObjectsFactory = internalObjectsFactory; // stateChangeEventHandle = new EventWaitHandle(false, EventResetMode.AutoReset); // internalPlayer = internalObjectsFactory.CreateVlcMediaPlayerInternal(); initializeEvents(); }
private void initializeEvents() { VlcMediaPlayerInternal player = internalPlayer; // IntPtr pFirstMediaPlayerInternalEventManager = LibVlcInterop.libvlc_media_player_event_manager(player.Descriptor); // Attaching to player attachToEvent(pFirstMediaPlayerInternalEventManager, new LibVlcInterop.VlcEventHandlerDelegate(playerInternal_TimeChanged), libvlc_event_type_e.libvlc_MediaPlayerTimeChanged); attachToEvent(pFirstMediaPlayerInternalEventManager, new LibVlcInterop.VlcEventHandlerDelegate(playerInternal_Stopped), libvlc_event_type_e.libvlc_MediaPlayerStopped); attachToEvent(pFirstMediaPlayerInternalEventManager, new LibVlcInterop.VlcEventHandlerDelegate(playerInternal_PositionChanged), libvlc_event_type_e.libvlc_MediaPlayerPositionChanged); attachToEvent(pFirstMediaPlayerInternalEventManager, new LibVlcInterop.VlcEventHandlerDelegate(playerInternal_EncounteredError), libvlc_event_type_e.libvlc_MediaPlayerEncounteredError); attachToEvent(pFirstMediaPlayerInternalEventManager, new LibVlcInterop.VlcEventHandlerDelegate(playerInternal_EndReached), libvlc_event_type_e.libvlc_MediaPlayerEndReached); // StateChanged events attachToEvent(pFirstMediaPlayerInternalEventManager, new LibVlcInterop.VlcEventHandlerDelegate(playerInternal_StateChanged), libvlc_event_type_e.libvlc_MediaPlayerOpening); attachToEvent(pFirstMediaPlayerInternalEventManager, new LibVlcInterop.VlcEventHandlerDelegate(playerInternal_StateChanged), libvlc_event_type_e.libvlc_MediaPlayerBuffering); attachToEvent(pFirstMediaPlayerInternalEventManager, new LibVlcInterop.VlcEventHandlerDelegate(playerInternal_StateChanged), libvlc_event_type_e.libvlc_MediaPlayerPlaying); attachToEvent(pFirstMediaPlayerInternalEventManager, new LibVlcInterop.VlcEventHandlerDelegate(playerInternal_StateChanged), libvlc_event_type_e.libvlc_MediaPlayerPaused); attachToEvent(pFirstMediaPlayerInternalEventManager, new LibVlcInterop.VlcEventHandlerDelegate(playerInternal_StateChanged), libvlc_event_type_e.libvlc_MediaPlayerSeekableChanged); attachToEvent(pFirstMediaPlayerInternalEventManager, new LibVlcInterop.VlcEventHandlerDelegate(playerInternal_StateChanged), libvlc_event_type_e.libvlc_MediaPlayerPausableChanged); }
/// <summary> /// Internal. /// </summary> protected override void PlayNextInternal() { if (nextMedia == null) { throw new MediaPlayerException("Next media is not selected."); } // Verify nexyMedia if (nextMedia.Type == MediaInputType.File) { if (!File.Exists(nextMedia.Source)) { throw new FileNotFoundException("File of media specified was not found.", nextMedia.Source); } } // VlcMediaPlayerInternal mediaplayer = internalPlayer; // create nextMediaInternal and start playing VlcMediaInternal nextMediaInternal = nextMediaInternalPreprepared; nextMediaInternalPreprepared = null; // nextMediaInternal.SetOutput(playerOutput); mediaplayer.SetMedia(nextMediaInternal); if (playerOutput.IsWindowDefined) { if (playerOutput.Window != null && playerOutput.Window is DoubleWindowBase) { // support old code internalPlayer.SetDisplayOutputHwnd(((DoubleWindowBase)playerOutput.Window).GetActiveWindowHandleInternal()); } else if (playerOutput.NativeWindow != null && playerOutput.NativeWindow is VlcNativeMediaWindow) { // this will tell what to method we should call to initialize window VlcNativeMediaWindow window = (VlcNativeMediaWindow)playerOutput.NativeWindow; if (window.WindowType == VlcWindowType.HWND) { internalPlayer.SetDisplayOutputHwnd(window.NativeWindowHandle); } else if (window.WindowType == VlcWindowType.NSObject) { internalPlayer.SetDisplayOutputNSObject(window.NativeWindowHandle); } else if (window.WindowType == VlcWindowType.XWindow) { internalPlayer.SetDisplayOutputXWindow(window.NativeWindowHandle); } else if (window.WindowType == VlcWindowType.Agl) { internalPlayer.SetDisplayOutputAgl(window.NativeWindowHandle); } } } // if (currentMediaInternal != null && disposeCurrentMedia) { currentMediaInternal.Dispose(); currentMediaInternal = null; } // currentMediaInternal = nextMediaInternal; disposeCurrentMedia = disposeNextMediaPreprepared; // startPlaying(); }