public VlcMediaInternal CreateVlcMediaInternal(MediaInput mediaInput) { if (mediaInput == null) { throw new ArgumentNullException("mediaInput"); } // libvlc_exception_t exc = new libvlc_exception_t(); LibVlcInterop.libvlc_exception_init(ref exc); IntPtr mediaDescriptor = LibVlcInterop.libvlc_media_new(vlclibDescriptor, mediaInput.Source, ref exc); if (exc.b_raised != 0) { throw new VlcInternalException(exc.Message); } // return new VlcMediaInternal(mediaDescriptor); }
/// <summary> /// Initializes next media. /// </summary> /// <param name="mediaInput">Specified media to play after <see cref="PlayNext"/> method call.</param> public abstract void SetNextMediaInput(MediaInput mediaInput);
/// <summary> /// Specifies current media input. /// </summary> public override void SetMediaInput(MediaInput mediaInput) { VerifyObjectIsNotDisposed(); // if (mediaInput == null) { throw new ArgumentNullException("mediaInput"); } // currentMedia = mediaInput; }
/// <summary> /// Specifies next media input. /// </summary> public override void SetNextMediaInput(MediaInput mediaInput) { VerifyObjectIsNotDisposed(); // if (mediaInput == null) { throw new ArgumentNullException("mediaInput"); } // nextMedia = mediaInput; // If nextMediaInternal was prepared to playing already we have to release it if (nextMediaInternal != null) { getNextMediaPlayerInternal().Stop(); nextMediaInternal.Dispose(); nextMediaInternal = null; } // If current player state is PLAYING we can prepare the nextMedia if (currentMediaInternal != null) { if ((currentMediaInternal.State == VlcMediaState.PLAYING) || (currentMediaInternal.State == VlcMediaState.PAUSED)) { prepareNextMedia(); } } }
/// <summary> /// Stop the current media playing and begin playing next. /// </summary> public override void PlayNext() { VerifyObjectIsNotDisposed(); // 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); } } // if (nextMediaInternal == null) { // Create nextMediaInternal and start playing in the inactiveWindow nextMediaInternal = internalObjectsFactory.CreateVlcMediaInternal(nextMedia); nextMediaInternal.SetOutput(playerOutput); getNextMediaPlayerInternal().SetMedia(nextMediaInternal); getNextMediaPlayerInternal().SetDisplayOutput((int) ((DoubleWindowBase) playerOutput.Window).GetInactiveWindowHandleInternal()); // startPlaying(getNextMediaPlayerInternal(), nextMediaInternal); } else { if (nextMediaInternal.State != VlcMediaState.PAUSED) { throw new MediaPlayerException("Next media has an unexpected state now."); } // getNextMediaPlayerInternal().Pause(); } // waitForMediaState(nextMediaInternal, VlcMediaState.PLAYING); if (nextMediaInternal.State != VlcMediaState.PLAYING) { throw new VlcTimeoutException("Timeout waiting required state."); } // ((DoubleWindowBase) playerOutput.Window).SwitchWindowsInternal(); // It is important to call this BEFORE stopping the player // if we want to EndReached event will not be raised incorrectly switchCurrentAndNextMediaPlayersInternal(); // if (currentMediaInternal != null) { if ((currentMediaInternal.State != VlcMediaState.IDLE_CLOSE) && (currentMediaInternal.State != VlcMediaState.ENDED)) { // It was _current_ player before the switchCurrentAndNextMediaPlayersInternal() call getNextMediaPlayerInternal().Stop(); // waitForMediaState(currentMediaInternal, VlcMediaState.ENDED); if (currentMediaInternal.State != VlcMediaState.ENDED) { throw new VlcTimeoutException("Timeout waiting required state."); } } // currentMediaInternal.Dispose(); currentMediaInternal = null; } // current := next currentMediaInternal = nextMediaInternal; nextMediaInternal = null; currentMedia = nextMedia; nextMedia = null; // ((DoubleWindowBase) playerOutput.Window).PlayerVisibleInternal = true; }