Ejemplo n.º 1
0
        /// <summary>
        /// Initializes previously preparsed next media to play.
        /// </summary>
        /// <param name="preparsedMedia">
        /// A <see cref="PreparsedMedia"/> instance returned from <see cref="ParseMediaInput"/> method.
        /// </param>
        public override void SetNextMediaInput(PreparsedMedia preparsedMedia)
        {
            VerifyObjectIsNotDisposed();
            //
            if (preparsedMedia == null)
            {
                throw new ArgumentNullException("mediaInput");
            }
            //
            nextMedia = preparsedMedia.MediaInput;
            // precreating of libvlc media
            if (currentMediaInternal != currentMediaInternalPreprepared)
            {
                if (nextMediaInternalPreprepared != null)
                {
                    nextMediaInternalPreprepared.Dispose();
                    nextMediaInternalPreprepared = null;
                }
            }
            VlcMediaInternal media = GetPreparsedMediaInternal(preparsedMedia);

            media.SetOutput(playerOutput);
            //
            nextMediaInternalPreprepared = media;
            disposeNextMediaPreprepared  = true;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Specifies next media input.
 /// </summary>
 public override void SetNextMediaInput(MediaInput mediaInput)
 {
     VerifyObjectIsNotDisposed();
     //
     if (mediaInput == null)
     {
         throw new ArgumentNullException("mediaInput");
     }
     //
     nextMedia = mediaInput;
     // precreating of libvlc media
     if (currentMediaInternal != currentMediaInternalPreprepared)
     {
         if (nextMediaInternalPreprepared != null)
         {
             nextMediaInternalPreprepared.Dispose();
             nextMediaInternalPreprepared = null;
         }
     }
     nextMediaInternalPreprepared = internalObjectsFactory.CreateVlcMediaInternal(nextMedia);
     nextMediaInternalPreprepared.SetOutput(playerOutput);
     disposeNextMediaPreprepared = true;
 }
Ejemplo n.º 3
0
        /// <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();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Starts playing of media which was initialized using <see cref="SetMediaInput"/> method.
 /// If some media is playing now it will be simply restarted.
 /// </summary>
 protected override void PlayInternal()
 {
     if (currentMedia == null)
     {
         throw new MediaPlayerException("Current media is null.");
     }
     if (playerOutput == null)
     {
         throw new MediaPlayerException("Player output is null.");
     }
     //
     if (currentMediaInternal != null)
     {
         if (currentMediaInternal.State == VlcMediaState.Paused)
         {
             Resume();
             return;
         }
         if (currentMediaInternal.State == VlcMediaState.Playing)
         {
             Position = 0f;
             return;
         }
         Stop();
     }
     // Verify currentMedia
     if (currentMedia.Type == MediaInputType.File)
     {
         if (!File.Exists(currentMedia.Source))
         {
             throw new FileNotFoundException("File of media specified was not found.", currentMedia.Source);
         }
     }
     if (currentMediaInternalPreprepared == null)
     {
         currentMediaInternalPreprepared = internalObjectsFactory.CreateVlcMediaInternal(currentMedia);
         currentMediaInternalPreprepared.SetOutput(playerOutput);
     }
     //
     currentMediaInternal            = currentMediaInternalPreprepared;
     currentMediaInternalPreprepared = null;
     disposeCurrentMedia             = disposeCurrentMediaPreprepared;
     //
     internalPlayer.SetMedia(currentMediaInternal);
     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);
             }
         }
     }
     //
     startPlaying();
 }