示例#1
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();
        }
示例#2
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();
 }